|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DataGridView row background colorHi, all,
Is there any way to change DataGridView row color based on different row data? for example, if row data in first column = 1, it is yellow, if it is 2, it is blue, if 3 it is white. That means how to loop DataGridData to get row data, then based on the different data to change row background color? Thanks in advance! Hello martin1,
after some modifications this will do... Dim CountR As Integer For CountR = 0 To GridView1.Rows.Count - 1 Select Case GridView1.Rows(CountR).Cells(1).Text Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral End Select Next Jack Show quoteHide quote > Hi, all, > > Is there any way to change DataGridView row color based on different > row data? for example, if row data in first column = 1, it is yellow, > if it is 2, it is blue, if 3 it is white. That means how to loop > DataGridData to get row data, then based on the different data to > change row background color? > > Thanks in advance! > Thank you. Jack
another question is do yuo know how to remove some columns from DataGridView? whcih feature and function is used for this? Thanks Show quoteHide quote "Jack" wrote: > Hello martin1, > after some modifications this will do... > > Dim CountR As Integer > > For CountR = 0 To GridView1.Rows.Count - 1 > Select Case GridView1.Rows(CountR).Cells(1).Text > Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow > Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet > Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua > Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral > End Select > > Next > > > Jack > > > > Hi, all, > > > > Is there any way to change DataGridView row color based on different > > row data? for example, if row data in first column = 1, it is yellow, > > if it is 2, it is blue, if 3 it is white. That means how to loop > > DataGridData to get row data, then based on the different data to > > change row background color? > > > > Thanks in advance! > > > > > martin1 wrote:
Show quoteHide quote > Thank you. Jack If the datasource is a datatable.> > another question is do yuo know how to remove some columns from > DataGridView? whcih feature and function is used for this? Thanks > > "Jack" wrote: > > > Hello martin1, > > after some modifications this will do... > > > > Dim CountR As Integer > > > > For CountR = 0 To GridView1.Rows.Count - 1 > > Select Case GridView1.Rows(CountR).Cells(1).Text > > Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow > > Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet > > Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua > > Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral > > End Select > > > > Next > > > > > > Jack > > > > > > > Hi, all, > > > > > > Is there any way to change DataGridView row color based on different > > > row data? for example, if row data in first column = 1, it is yellow, > > > if it is 2, it is blue, if 3 it is white. That means how to loop > > > DataGridData to get row data, then based on the different data to > > > change row background color? > > > > > > Thanks in advance! > > > > > > > > > Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden B. Thank you. Brian,
how about datasource is DataGridView? which is pupulated from dataset Show quoteHide quote "Brian Tkatch" wrote: > > martin1 wrote: > > Thank you. Jack > > > > another question is do yuo know how to remove some columns from > > DataGridView? whcih feature and function is used for this? Thanks > > > > "Jack" wrote: > > > > > Hello martin1, > > > after some modifications this will do... > > > > > > Dim CountR As Integer > > > > > > For CountR = 0 To GridView1.Rows.Count - 1 > > > Select Case GridView1.Rows(CountR).Cells(1).Text > > > Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow > > > Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet > > > Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua > > > Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral > > > End Select > > > > > > Next > > > > > > > > > Jack > > > > > > > > > > Hi, all, > > > > > > > > Is there any way to change DataGridView row color based on different > > > > row data? for example, if row data in first column = 1, it is yellow, > > > > if it is 2, it is blue, if 3 it is white. That means how to loop > > > > DataGridData to get row data, then based on the different data to > > > > change row background color? > > > > > > > > Thanks in advance! > > > > > > > > > > > > > > > If the datasource is a datatable. > > Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden > > B. > > I figure now
DataGridView.Columns(colume_name).Visible = False Show quoteHide quote "martin1" wrote: > Thank you. Brian, > > how about datasource is DataGridView? which is pupulated from dataset > > "Brian Tkatch" wrote: > > > > > martin1 wrote: > > > Thank you. Jack > > > > > > another question is do yuo know how to remove some columns from > > > DataGridView? whcih feature and function is used for this? Thanks > > > > > > "Jack" wrote: > > > > > > > Hello martin1, > > > > after some modifications this will do... > > > > > > > > Dim CountR As Integer > > > > > > > > For CountR = 0 To GridView1.Rows.Count - 1 > > > > Select Case GridView1.Rows(CountR).Cells(1).Text > > > > Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow > > > > Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet > > > > Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua > > > > Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral > > > > End Select > > > > > > > > Next > > > > > > > > > > > > Jack > > > > > > > > > > > > > Hi, all, > > > > > > > > > > Is there any way to change DataGridView row color based on different > > > > > row data? for example, if row data in first column = 1, it is yellow, > > > > > if it is 2, it is blue, if 3 it is white. That means how to loop > > > > > DataGridData to get row data, then based on the different data to > > > > > change row background color? > > > > > > > > > > Thanks in advance! > > > > > > > > > > > > > > > > > > > > > If the datasource is a datatable. > > > > Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden > > > > B. > > > > martin1 wrote:
Show quoteHide quote > Thank you. Brian, Then go up first. :)> > how about datasource is DataGridView? which is pupulated from dataset > > "Brian Tkatch" wrote: > > > > > martin1 wrote: > > > Thank you. Jack > > > > > > another question is do yuo know how to remove some columns from > > > DataGridView? whcih feature and function is used for this? Thanks > > > > > > "Jack" wrote: > > > > > > > Hello martin1, > > > > after some modifications this will do... > > > > > > > > Dim CountR As Integer > > > > > > > > For CountR = 0 To GridView1.Rows.Count - 1 > > > > Select Case GridView1.Rows(CountR).Cells(1).Text > > > > Case "Austria" : GridView1.Rows(CountR).BackColor = Drawing.Color.Yellow > > > > Case "Brazil" : GridView1.Rows(CountR).BackColor = Drawing.Color.Violet > > > > Case "Belgium" : GridView1.Rows(CountR).BackColor = Drawing.Color.Aqua > > > > Case Else : GridView1.Rows(CountR).BackColor = Drawing.Color.Coral > > > > End Select > > > > > > > > Next > > > > > > > > > > > > Jack > > > > > > > > > > > > > Hi, all, > > > > > > > > > > Is there any way to change DataGridView row color based on different > > > > > row data? for example, if row data in first column = 1, it is yellow, > > > > > if it is 2, it is blue, if 3 it is white. That means how to loop > > > > > DataGridData to get row data, then based on the different data to > > > > > change row background color? > > > > > > > > > > Thanks in advance! > > > > > > > > > > > > > > > > > > > > > If the datasource is a datatable. > > > > Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden > > > > B. > > > > MyDataGridView.DataSource.Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden Just like every DataTable has a link to it's DefaultView every DataView has a link to it's (parent) Table. BTW, if you want context-sensitive help to appear, you have to tell the editor whatr the DataSource is, since it otherwise will not know (since it can be a DataSet, DataTable, DataView...), and this is (one of the things) done via CType. CType(MyDataGridView.DataSource, DataView).Table.Columns(Column_Name).ColumnMapping() = MappingType.Hidden B.
ASP.NET web application - date conversions UK date format?
Building a single EXE file in VB 2005? What errors are not trappable? default in .NET byref or byval? Build Failed - 0 Errors Adding ActiveX controls at runtime and threading How to gain access to objet in different class ? Define a compilation switch Listbox help Dynamically Creating A CSS Class |
|||||||||||||||||||||||