Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net vbnet datagridview中的单元格值更改事件出错_Vb.net_Datagridview - Fatal编程技术网

Vb.net vbnet datagridview中的单元格值更改事件出错

Vb.net vbnet datagridview中的单元格值更改事件出错,vb.net,datagridview,Vb.net,Datagridview,我只是简单地添加了消息框,当我运行表单时,消息框会一直弹出,直到所有的行都加载完毕 我最初的计划是显示一条消息,说明您已编辑了单元格。当加载gridview并从数据库中提取行时,或者当您更改单元格的值时,也会发生单元格更改事件。 如何阻止消息框无数次弹出,以及我是否使用了错误的事件??下面就是我所做的。我还使用datasource从数据库中获取记录 Private Sub grdDataGrid_CellValueChanged(sender As Object, e As DataGridVi

我只是简单地添加了消息框,当我运行表单时,消息框会一直弹出,直到所有的行都加载完毕

我最初的计划是显示一条消息,说明您已编辑了单元格。当加载gridview并从数据库中提取行时,或者当您更改单元格的值时,也会发生单元格更改事件。 如何阻止消息框无数次弹出,以及我是否使用了错误的事件??下面就是我所做的。我还使用datasource从数据库中获取记录

Private Sub grdDataGrid_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles grdDataGrid.CellValueChanged


    MsgBox("You have edited the follwing cell")


End Sub

要阻止messageBox无数次弹出,请执行以下操作:

Private Sub grdDataGrid_DataBindingComplete(sender As Object, e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles grdDataGrid.DataBindingComplete

MessageBox("your message")

End Sub

使用_CellValueChanged事件时-渲染gridView时,加载数据的所有单元格都会发生更改。因此,每个单元格都会触发_CellValueChanged事件定义的数据绑定是数据集还是适配器??很抱歉,我对这一点还是新手,即使你说了发生这种情况的条件。很抱歉,你正在开发一个windows窗体应用程序,我给了你ASP.NET的代码。我已经编辑了我的回复。我相信您希望在单元格的值被更改并绑定到网格后,在DataBindingComplete上显示消息。是的,我厌倦了cellEndEdit,如果它是一个组合框,并且在我选择了值cellEndEdit后,它会一直工作。cellEndEdit仅在我离开单元格后才会触发。如果编辑时发生事件。因为事件只有在我确认编辑后才起作用。这是一个额外的问题,我已经接受了你的答案。顺便说一句,你需要使用组合框的事件。另一个解决方案是使用网格的_CellLeave事件。在您编辑的单元格不再具有焦点后,\ u CellLeave事件将触发。但是gridview中的组合框是否可以使用begin edit或cell focus事件?