.Net:DataGridView响应IBinding.ListChanged但不响应CellValueChanged事件处理程序

时间:2010-08-18 22:39:18

标签: .net events datagridview

我有一个自定义的IBinding List,它会引发ListChanged事件。我想在ListChanged事件之后重新着色Datagridview行。

Datagridview正在响应ListChanged事件并更改单元格值,但从未触发CellValueChanged事件。

哪些Datagridview事件反映了ListChanged事件?

Class CustomList:IBinding

Public Sub UpdateList(Byval index as Integer)
     List(index).Active = true
     RaiseEvent ListChanged(Me, _
        New System.ComponentModel.ListChangedEventArgs _
        (System.ComponentModel.ListChangedType.ItemChanged, index))
End Sub

类CustomDataGridView:DataGridView

Private Sub Grid_CellValueChanged(ByVal sender As Object, _
            ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
            Handles Me.CellValueChanged
     ColorRow(Rows(e.RowIndex)) ''//NeverFires
End Sub

类:表单

Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
                Handles Me.Load

        Dim customList As New CustomList()
        customList.add(new CustomItem())
        dgv.DataSource = customList
        customList.UpdateList(0) ''//DatagridView updates but no event is raised

End Sub

更新

  

CellValueChanged事件仅在触发时触发   一个新值从DGV推送到   DT。不是其他方式。

- Vivek Apr 5 at 18:52

1 个答案:

答案 0 :(得分:0)

更改单元格背景颜色应该在RowPrePaint-Event中完成,如果在值更改后重新绘制行,则会触发此操作。