Hi all
Got the following code:
The idea being that the DGV is loaded from a text file, and if the relevant column (checkbox) value is true, then the cells in Column 2 go blue with white font.Code:Dim i As Integer DataGridView1.AllowUserToAddRows = True If Not DataGridView1.LoadTextFile("C:\test.txt", ErrorList) Then Dim sb As New System.Text.StringBuilder sb.AppendLine("Failed to load text file, see error messages below.") For Each item In ErrorList sb.AppendLine(item) Next MessageBox.Show(sb.ToString) End If If CBool(Me.DataGridView1.Rows(i).Cells(3).Value) = True Then DataGridView1.Rows(i).Cells("Column2").Style.BackColor = Color.Blue DataGridView1.Rows(i).Cells("Column2").Style.ForeColor = Color.White End If
However, this only works if the datagridview is loaded with one row of data and needs to be repeated for however many rows might be loaded.
thanks for advice and time!




Reply With Quote
