1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
public void SelectAllRows()
{
if (!MultiSelect) return;
foreach (DataGridViewRow row in Rows)
{
if (!SelectedIndicess.Contains(row.Index))
{
AddSelectedRowWithoutRefresh(row.Index, true);
}
}
allSelected = true;
Refresh();
}
public bool AddSelectedRowWithoutRefresh(int rowIndex, bool fromMultipleSelections)
{
if (rowIndex >= 0)
{
if (!this.MultiSelect)
{
ClearAllRowsWitoutRefresh();
}
if (!SelectedIndicess.Contains(rowIndex))
{
if (AddIndex(rowIndex, fromMultipleSelections))
return true;
}
Rows[rowIndex].DefaultCellStyle.BackColor = m_SelectionColor;
Rows[rowIndex].DefaultCellStyle.SelectionBackColor = m_SelectionColor;
return false;
}
return true;
}
private bool AddIndex(int rowIndex, bool fromMultipleSelections)
{
if (BeforeRowSelectionChanged(Rows[rowIndex], fromMultipleSelections))
return true;
SelectedIndicess.Add(rowIndex);
Rows[rowIndex].Cells[0].Value = true;
AfterRowSelectionChanged(Rows[rowIndex], fromMultipleSelections);
return false;
} |
Partager