From: Ivan Zlatev Date: Thu, 19 Mar 2009 18:09:38 +0000 (-0000) Subject: 2009-03-19 Ivan N. Zlatev X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=27894abb99e01e79bb967bb04498b0883f535d00;p=mono.git 2009-03-19 Ivan N. Zlatev * DataGridView.cs, DataGridViewCellCollection.cs: Split the column removal to perform Pre and Post removal actions to allow the current cell to be moved and all events fired properly before the column is removed. svn path=/trunk/mcs/; revision=129803 --- diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 62d5e968dac..9532c18b13b 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,9 @@ +2009-03-19 Ivan N. Zlatev + + * DataGridView.cs, DataGridViewCellCollection.cs: Split the column removal + to perform Pre and Post removal actions to allow the current cell to be + moved and all events fired properly before the column is removed. + 2009-03-19 Ivan N. Zlatev * DataGridView.cs, DataGridViewRow.cs: Split the row removal to perform Pre and diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs index 7a0d8d52e57..ffc8bd7c59b 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs @@ -3848,7 +3848,22 @@ namespace System.Windows.Forms { eh (this, e); } - internal void OnColumnRemovedInternal (DataGridViewColumnEventArgs e) + internal void OnColumnPreRemovedInternal (DataGridViewColumnEventArgs e) + { + if (Columns.Count - 1 == 0) { + MoveCurrentCell (-1, -1, true, false, false, true); + rows.ClearInternal (); + } else if (currentCell != null && CurrentCell.ColumnIndex == e.Column.Index) { + int nextColumnIndex = e.Column.Index; + if (nextColumnIndex >= Columns.Count - 1) + nextColumnIndex = Columns.Count - 1 - 1; + MoveCurrentCell (nextColumnIndex, currentCell.RowIndex, true, false, false, true); + if (hover_cell != null && hover_cell.ColumnIndex >= e.Column.Index) + hover_cell = null; + } + } + + private void OnColumnPostRemovedInternal (DataGridViewColumnEventArgs e) { if (e.Column.CellTemplate != null) { int index = e.Column.Index; @@ -3859,17 +3874,6 @@ namespace System.Windows.Forms { AutoResizeColumnsInternal (); PrepareEditingRow (false, true); - if (Columns.Count == 0) { - rows.ClearInternal (); - MoveCurrentCell (-1, -1, true, false, false, true); - } else if (currentCell != null && CurrentCell.ColumnIndex == e.Column.Index) { - int nextColumnIndex = e.Column.Index; - if (nextColumnIndex >= Columns.Count) - nextColumnIndex = Columns.Count - 1; - MoveCurrentCell (nextColumnIndex, currentCell.RowIndex, true, false, false, true); - if (hover_cell != null && hover_cell.ColumnIndex >= e.Column.Index) - hover_cell = null; - } OnColumnRemoved (e); } @@ -5696,7 +5700,7 @@ namespace System.Windows.Forms { OnColumnAddedInternal(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn)); break; case CollectionChangeAction.Remove: - OnColumnRemovedInternal(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn)); + OnColumnPostRemovedInternal(new DataGridViewColumnEventArgs(e.Element as DataGridViewColumn)); break; case CollectionChangeAction.Refresh: break; diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs index c5bbd9c4d6b..f2242dd5788 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnCollection.cs @@ -198,6 +198,7 @@ namespace System.Windows.Forms public virtual void Remove (DataGridViewColumn dataGridViewColumn) { + DataGridView.OnColumnPreRemovedInternal (new DataGridViewColumnEventArgs (dataGridViewColumn)); base.List.Remove (dataGridViewColumn); OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Remove, dataGridViewColumn)); }