dotnetmonitor.com |
|
|||||||||||||
| The DataGridView control provides you with a
variety of options for configuring how users can select cells, rows, and
columns. For example, you can enable single or multiple selection, selection of
whole rows or columns when users click cells, or selection of whole rows or
columns only when users click their headers, which enables cell selection as
well. If you want to provide your own user interface for selection, you can
disable ordinary selection and handle all selection programmatically.
Additionally, you can enable users to copy the selected values to the
Clipboard.
Sometimes you want your application to perform actions based on user selections within a DataGridView control. Depending on the actions, you may want to restrict the kinds of selection that are possible. For example, suppose your application can print a report for the currently selected record. In this case, you may want to configure the DataGridView control so that clicking anywhere within a row always selects the entire row, and so that only one row at a time can be selected.
You can specify the selections allowed by setting the SelectionMode property to one of the following DataGridViewSelectionMode enumeration values.
Note: Changing the selection mode at run time automatically clears the current selection. By default, users can select multiple rows, columns, or cells by dragging with the mouse, pressing CTRL or SHIFT while selecting to extend or modify a selection, or clicking the top-left header cell to select all cells in the control. To prevent this behavior, set the MultiSelect property to false.
The FullRowSelect and RowHeaderSelect modes allow users to delete rows by selecting them and pressing the DELETE key. Users can delete rows only when the current cell is not in edit mode, the AllowUserToDeleteRows property is set to true, and the underlying data source supports user-driven row deletion. Note that these settings do not prevent programmatic row deletion. |
|||||||||||||
|
|||||||||||||