[MWF] Fix bug in DataGridViewRowCollection Clear() introduced by recent commit
commitfb7332bec128c08c7a84a4fb14a97dc846b96d59
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 27 Nov 2014 04:29:32 +0000 (27 05:29 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 27 Nov 2014 11:11:20 +0000 (27 12:11 +0100)
tree60b98e4946e63f262bfd6ddbbd6b1d42fa0de458
parentb044fa0f26a3ca80bda0c279cec39917186008e0
[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.
mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowCollection.cs