简体   繁体   English

vbnet datagridview中的单元格值更改事件错误

[英]error on cell value change event in vbnet datagridview

I simply added message box and when i run the form the message box keeps popping up until all the rows have finish loaded n gridview. 我只是添加了消息框,当我运行表单时,消息框一直弹出,直到所有行都已加载到gridview中。

My initial plan was to show a message that you have edited the cell. 我最初的计划是显示一条消息,说明您已编辑单元格。 So does cell change event happens when the gridview is being loaded and extracting the rows from the database or when you change the value of cell. 当加载gridview并从数据库中提取行时,或者更改单元格的值时,单元格更改事件也会发生。 How to stop the message box from popping out countless of times and whether or not i am using the wrong event?? 如何阻止消息框弹出无数次,以及我是否使用了错误的事件? Below is exactly what i did. 以下正是我所做的。 I am also using datasource to get my records from the database 我也在使用数据源从数据库中获取记录

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


    MsgBox("You have edited the follwing cell")


End Sub

To stop the messageBox from popping out countless times: 要阻止messageBox弹出无数次:

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

MessageBox("your message")

End Sub

When you use the _CellValueChanged event- all of the cells that are being loaded with data are being changed when you render the gridView. 当使用_CellValueChanged事件时,呈现gridView时将更改所有正在加载数据的单元格。 So each cell is firing the _CellValueChanged event 因此,每个单元格都会触发_CellValueChanged事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM