Posts

Showing posts from May 7, 2024

VB .NET WinForms Datagridview.CellValueChanged event fires multiple times (Solved)

Image
Solution for  DataGridview.CellValueChanged Event fires multiple times. Datagridview.CellValuechanged event fires multiple times   - When you use Visual Studio to develop a WinForms application that contains Datagridview CheckBox Column. One of the Events that you may use to Change the Values in the Cells is [ CellValueChanged ] event.  You will notice 'if you debug your code', that this Event fires multiple times while executing. - Here is a solution for this multiple firing issue : Code Private Sub DatagridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs)         If TypeOf DatagridView1.CurrentCell Is DataGridViewCheckBoxCell Then             Dim ChkCnt As Integer             Dim columnIndex As Integer = OptCol.Index             If e.ColumnIndex = columnIndex Then                 Dim isChecked As Boolean = CBool(DatagridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)                 RemoveHandler DatagridView1.CellValueChanged, AddressOf DatagridView