tarunkapoor
Member
- Joined
- Apr 10, 2005
- Messages
- 17
- Programming Experience
- 3-5
I have made a user control which is inherited from DataGridView(DGV). Depending on certain conditions i have to add data to DGV, for which i add more rows to the DGV.
I have the following code in a function in the inherited class.
'currentBindingSource is of type BindingSource
For i = 0 To numColumns
If ((startRow + i) >= Me.Rows.Count) Then
When a new row is added in the underlying list of the binding source using the above code, the following event is raised.
Protected Overrides Sub OnRowsAdded(ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs)
The problem is that sometimes the onRowsAdded event is called twice on a single addnew() call. As a result the total number of rows in the DGV increases while the row index of the added row doesnt increase by same amount.
Also sometimes the row index of the added row as shown in the onrowsadded event has the same value as it was the last time the event was raised. This is not possible because the row index should increase every time.
I have filed a bug report about this at MSDN.
Has anyone had similar problems.?? or knows whats going on ?
I have the following code in a function in the inherited class.
'currentBindingSource is of type BindingSource
For i = 0 To numColumns
If ((startRow + i) >= Me.Rows.Count) Then
currentBindingSource.AddNew()
'More CODE
End If'More CODE
When a new row is added in the underlying list of the binding source using the above code, the following event is raised.
Protected Overrides Sub OnRowsAdded(ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs)
MessageBox.Show("OnRowsAdded of custom DGV raised for Row Num : " & e.RowIndex)
MessageBox.Show("RowIndex:" & e.RowIndex)
MyBase.OnRowsAdded(e)
End SubMessageBox.Show("RowIndex:" & e.RowIndex)
MyBase.OnRowsAdded(e)
The problem is that sometimes the onRowsAdded event is called twice on a single addnew() call. As a result the total number of rows in the DGV increases while the row index of the added row doesnt increase by same amount.
Also sometimes the row index of the added row as shown in the onrowsadded event has the same value as it was the last time the event was raised. This is not possible because the row index should increase every time.
I have filed a bug report about this at MSDN.
Has anyone had similar problems.?? or knows whats going on ?