我有一個綁定到DataSet的DataGridView。我有一個CheckBox列。當我希望行在用戶檢查特定行時立即改變顏色。我可以用我的代碼改變顏色,但由於某種原因,我不知道..只有當我離開單元格時纔會改變顏色。選中CheckBox時更改DataGridView Row的顏色。
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...
有關如何添加' DataGridView1.Refresh()'? –
仍是同樣的故事。 – Arbaaz
使用CellEndEdit ... – Codexer