mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 01:41:18 -10:00
[MWF] DataGridView: ensure first_row_index will be valid after row removal
DataGridView keeps track of the first visible row in first_row_index. DataGridViewRowCollection will notify DataGridView its about to delete 1 or more rows via OnRowsPreRemovedInternal(). When this happens, we need to ensure first_row_index will still fall within the number of rows that will remain after the row removal. This fixes https://bugzilla.xamarin.com/show_bug.cgi?id=24372 which I reported.
This commit is contained in:
1 parent
c09cd684b4
commit
5a5c683696
1 file changed
+10
-3
@@ -5133,7 +5133,14 @@ namespace System.Windows.Forms {
|
||||
SetSelectedRowCore (rowIndex, false);
|
||||
}
|
||||
|
||||
if (Rows.Count - e.RowCount <= 0) {
|
||||
int RowsLeft = Rows.Count - e.RowCount;
|
||||
if (RowsLeft < 0)
|
||||
RowsLeft = 0;
|
||||
|
||||
if (first_row_index > RowsLeft)
|
||||
first_row_index = RowsLeft;
|
||||
|
||||
if (RowsLeft == 0) {
|
||||
MoveCurrentCell (-1, -1, true, false, false, true);
|
||||
hover_cell = null;
|
||||
} else if (Columns.Count == 0) {
|
||||
@@ -5141,8 +5148,8 @@ namespace System.Windows.Forms {
|
||||
hover_cell = null;
|
||||
} else if (currentCell != null && currentCell.RowIndex == e.RowIndex) {
|
||||
int nextRowIndex = e.RowIndex;
|
||||
if (nextRowIndex >= Rows.Count - e.RowCount)
|
||||
nextRowIndex = Rows.Count - 1 - e.RowCount;
|
||||
if (nextRowIndex >= RowsLeft)
|
||||
nextRowIndex = RowsLeft - 1;
|
||||
MoveCurrentCell (currentCell != null ? currentCell.ColumnIndex : 0, nextRowIndex,
|
||||
true, false, false, true);
|
||||
if (hover_cell != null && hover_cell.RowIndex >= e.RowIndex)
|
||||
|
||||
Reference in new issue
Block a user