净:DataGridView的响应IBinding.ListChanged但不CellValueChanged事件处理程序 [英] .Net: DataGridView Responding to IBinding.ListChanged but not CellValueChanged Event Handler

查看:123
本文介绍了净:DataGridView的响应IBinding.ListChanged但不CellValueChanged事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义IBinding一览表中引发ListChanged事件。我想ListChanged事件后重新着色DataGridView的一行。

I have a custom IBinding List which raises the ListChanged event. I would like to recolor the Datagridview row after the ListChanged event.

在DataGridView正在响应ListChanged事件并更改单元格的值,但CellValueChanged事件从来没有发射。

The Datagridview is responding to ListChanged event and changes the cell value but the CellValueChanged event is never fired.

什么datagridview的事件反映了ListChanged事件?

What Datagridview event reflects the ListChanged event?

类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。不是倒过来。

CellValueChanged event only fires when a new value is pushed from the DGV to the DT. Not other way round.

- <一个href="http://stackoverflow.com/questions/2580269/datagridview-cellvaluechanged-not-firing-on-bound-datagridview/3201856#3201856">Vivek 4月5日在18:52

推荐答案

更​​改单元格背景颜色应在行prePaint-事件来完成,如果该行被粉刷一新,这将被解雇,值更改后​​。

Changing the cells background color should be done in the RowPrePaint-Event, this will be fired if the row is repainted, after the value change.

这篇关于净:DataGridView的响应IBinding.ListChanged但不CellValueChanged事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆