Hello Michael,
Thanks for your effort.
You are right, after we call the DataGridView.Rows.RemoveAt(), the RowsRemoved event gets fired. However, as the message is still processed by the ComboBox control, a new row is added. Here is the callstack after the message is processed by DataGridView.
> DataGridViewTest.exe!DataGridViewTest.Form1.dataGridView1_RowsAdded(object sender = {SBRMaintenanceSpace.SBRDataGridView}, System.Windows.Forms.DataGridViewRowsAddedEventArgs e = {System.Windows.Forms.DataGridViewRowsAddedEventArgs}) Line 32 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnRowsAdded(System.Windows.Forms.DataGridViewRowsAddedEventArgs e) Line 18639 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnRowsAddedInternal(int rowIndex, int rowCount) Line 18629 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_PostNotification(System.ComponentModel.CollectionChangeAction cca = Add, int rowIndex = 0, int rowCount, System.Windows.Forms.DataGridViewRow dataGridViewRow = {DataGridViewRow { Index=-1 }}, bool changeIsDeletion = false, bool changeIsInsertion = false, bool recreateNewRow = false, System.Drawing.Point newCurrentCell) Line 2227 + 0x34 bytes C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged(System.ComponentModel.CollectionChangeEventArgs e, int rowIndex, int rowCount) Line 2058 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRowCollection.AddInternal(bool newRow, object[] values) Line 414 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.AddNewRow(bool createdByEditing = true) Line 77 + 0x20 bytes C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.OnCurrentCellDirtyStateChanged(System.EventArgs e = {System.EventArgs}) Line 14932 + 0xc bytes C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.IsCurrentCellDirtyInternal.set(bool value) Line 3574 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridView.NotifyCurrentCellDirty(bool dirty = true) Line 10580 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewComboBoxEditingControl.NotifyDataGridViewOfValueChange() Line 161 C#
System.Windows.Forms.dll!System.Windows.Forms.DataGridViewComboBoxEditingControl.OnSelectedIndexChanged(System.EventArgs e) Line 171 C#
System.Windows.Forms.dll!System.Windows.Forms.ComboBox.SelectedIndex.set(int value) Line 1029 C#
System.Windows.Forms.dll!System.Windows.Forms.ComboBox.InterceptAutoCompleteKeystroke(System.Windows.Forms.Message m) Line 2153 C#
System.Windows.Forms.dll!System.Windows.Forms.ComboBox.ProcessKeyEventArgs(ref System.Windows.Forms.Message m = {msg=0x100 (WM_KEYDOWN) hwnd=0x460eca wparam=0x2e lparam=0x1530001 result=0x0}) Line 2856 + 0x3f bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Control.ProcessKeyMessage(ref System.Windows.Forms.Message m) Line 10332 + 0xc bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WmKeyChar(ref System.Windows.Forms.Message m = {msg=0x100 (WM_KEYDOWN) hwnd=0x460eca wparam=0x2e lparam=0x1530001 result=0x0}) Line 12877 + 0xc bytes C#
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 13695 C#
System.Windows.Forms.dll!System.Windows.Forms.ComboBox.WndProc(ref System.Windows.Forms.Message m) Line 3676 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Line 14051 C#
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 14106 C#
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 256, System.IntPtr wparam, System.IntPtr lparam) Line 777 + 0xa bytes C#
Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact
msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.