dotnetmonitor.com |
|
||||||||||||
| The SelectedCells collection does not perform
efficiently with large selections. The SelectedRows and SelectedColumns
collections can also be inefficient, although to a lesser degree because there
are many fewer rows than cells in a typical DataGridView control, and many
fewer columns than rows. To avoid performance penalties when working with these
collections, use the following guidelines:
To determine whether all the cells in the DataGridView have been selected before you access the contents of the SelectedCells collection, check the return value of the AreAllCellsSelected method. Note, however, that this method can cause rows to become unshared. For more information, see the next section.
Avoid using the Count property of the DataGridViewSelectedCellCollection to determine the number of selected cells. Instead, use the GetCellCount() method and pass in the DataGridViewElementStates.Selected value. Similarly, use the DataGridViewRowCollection.GetRowCount() and DataGridViewColumnCollection.GetColumnCount() methods to determine the number of selected elements, rather than accessing the selected row and column collections.
Avoid cell-based selection modes. Instead, set the SelectionMode property to FullRowSelect or FullColumnSelect. |
||||||||||||
|
||||||||||||