Tuesday, 16 August 2016

c# - Changing Color of DataGridView Row when CheckBox is checked.

I have a DataGridView which is bound to a DataSet. I have a CheckBox Column. When I want the row to change color as soon as user checks a particular row. I am able to change the color with my code but for some reason unknown to me.. the color gets changed only when I leave the cell.



Private Sub DataGridView1_CellValueChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
If DataGridView1.Columns(e.ColumnIndex).Name = "ColCheck" Then
If DataGridView1.Rows(e.RowIndex).Cells("ColCheck").Value = True Then


DataGridView1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.LightGreen
''' blah blah blah...

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...