Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2014-11-27 07:29:32 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2014-11-27 14:11:20 +0300
commitfb7332bec128c08c7a84a4fb14a97dc846b96d59 (patch)
tree60b98e4946e63f262bfd6ddbbd6b1d42fa0de458 /mcs/class/Managed.Windows.Forms
parentb044fa0f26a3ca80bda0c279cec39917186008e0 (diff)
[MWF] Fix bug in DataGridViewRowCollection Clear() introduced by recent commit
7d1b878fbf13462a282860c6d1dd493a48d7b1eb altered the behavior of removing rows, breaking the DataGridViewRowCollectionTest.ClearRows () test Before the change, this is what happened when the list was cleared (the number in brackets is the value of the Index property of the DataGridViewRow): [0] Remove [1] ReIndex [0] Remove [1] ReIndex [0] [1] --------> [2] --------> [1] ------> [2] -------> [1] ... [2] [3] [2] [3] After the offending commit, ReIndex is only called after the list is cleared, which means the Index property of the rows is never updated (as there are no items in the list). The fix is to explicitly set the Index of each row to 0. This was the end result before the commit anyway, so we can omit the ReIndex call entirely.
Diffstat (limited to 'mcs/class/Managed.Windows.Forms')
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs
index 9badc1dc7ab..24aa28797ba 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs
@@ -261,7 +261,8 @@ namespace System.Windows.Forms
for (int i = 0; i < total; i++) {
DataGridViewRow row = (DataGridViewRow)list[0];
-
+ row.SetIndex(0);
+
// We can exit because the NewRow is always last
if (row.IsNewRow)
break;
@@ -270,7 +271,6 @@ namespace System.Windows.Forms
list.Remove (row);
}
- ReIndex ();
DataGridView.OnRowsPostRemovedInternal (new DataGridViewRowsRemovedEventArgs (0, total));
OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Refresh, null));
}