|
-
May 8th, 2012, 05:18 PM
#1
Thread Starter
Addicted Member
DGV CheckBox
Hi
I have code which saves DGV contents including check box columns as a comma separated text file. I also have correct code which will take the text file and re-insert it into the DGV at a later time. This all works.
When I'm working on the DGV, I have this code:
Code:
Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If DataGridView1.Columns(e.ColumnIndex).Name = "Column12" Then
Dim clrscript As Color
If DataGridView1.Rows(e.RowIndex).Cells("Column12").Value = True Then
clrscript = Color.DarkRed
DataGridView1.Rows(e.RowIndex).Cells("Column1").Style.BackColor = Color.FromArgb(183, 0, 0)
DataGridView1.Rows(e.RowIndex).Cells("Column3").Style.BackColor = Color.FromArgb(183, 0, 0)
ElseIf DataGridView1.Rows(e.RowIndex).Cells("Column12").Value = False Then
DataGridView1.Rows(e.RowIndex).Cells("Column1").Style.BackColor = Color.FromArgb(255, 192, 0)
DataGridView1.Rows(e.RowIndex).Cells("Column3").Style.BackColor = Color.FromArgb(255, 192, 0)
End If
End If
End Sub
So that when the check box is true, columns 1 and 3 turn different colours, and when false, go to a yellow colour.
However, when I "re-insert" my DGV info from my text file, the check boxes come back correctly - as true and false on the right rows - but columns 1 and 3 don't change colour. I've tried a "DataGridView1.Refresh" option but not getting it to work.
The DGV is unbound. I need it to recognise which check boxes are true and update automatically when the information is opened from a text file.
Thanks for your help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|