简体   繁体   中英

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.

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. 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:

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. So each cell is firing the _CellValueChanged event

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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