dotnetmonitor.com |
|
||||||||||||
| The current
selection mode restricts the behavior of programmatic selection as well as user
selection. You can change the current selection programmatically by setting the
Selected property of any cells, rows, or columns present in the DataGridView
control. You can also select all cells in the control through the SelectAll
method, depending on the selection mode. To clear the selection, use the
ClearSelection method.
If the MultiSelect property is set to true, you can add DataGridView elements to or remove them from the selection by changing the Selected property of the element. Otherwise, setting the Selected property to true for one element automatically removes other elements from the selection.
Note that changing the value of the CurrentCell property does not alter the current selection.
You can retrieve a collection of the currently selected cells, rows, or columns through the SelectedCells, SelectedRows, and SelectedColumns properties of the DataGridView control. Accessing these properties is inefficient when every cell in the control is selected. To avoid a performance penalty in this case, use the AreAllCellsSelected method first. Additionally, accessing these collections to determine the number of selected cells, rows, or columns can be inefficient. Instead, you should use the GetCellCount, GetRowCount, or GetColumnCount method, passing in the Selected value. |
||||||||||||
|
||||||||||||