MultiRow Windows Forms > Developer's Guide > Using MultiRow > Headers > Selecting Cells using Headers |
Use the HeaderCell.SelectionMode property to select cells using headers. This property sets the area or range that is selected when the header is clicked. This property can be used in the ColumnHeaderCell, RowHeaderCell, or CornerHeaderCell sections which inherit from header cell.
![]() |
If sorting using a header has been enabled for a header, you cannot select cells using this same header. |
You can specify that only cells within the header area are selected when the user clicks on the header if the HeaderCell.SelectionMode property has been set to ContainedCells.
The following image shows what happens when the user clicks on a column header, how the column header area is calculated, and how the cells are selected. Note that the cells lying partially inside the column header area are not the target for selection.
The calculation for the header area uses the cell width for column headers and cell height for row headers.
All the cells included in the header area are selected when the user clicks on a header if the HeaderCell.SelectionMode property has been set to IntersectedCells.
The following image shows what happens when the user clicks on a column header, how the column header area is calculated, and how the cells are selected. Note that the cells lying partially inside the column header area are also a target for selection.
The calculation of the header area uses the cell width for column headers and cell height for row headers.
The entire row is selected when the user clicks on the header if the HeaderCell.SelectionMode property has been set to Row. You cannot specify this value in the column header cell.
All the rows in the grid are selected when the user clicks on the header if the HeaderCell.SelectionMode property has been set to AllRows. You cannot specify this value in the row header cell. The default value of the SelectionMode property in the corner header cell is AllRows.
The cells are not selected if the user clicks on the header when the HeaderCell.SelectionMode property has been set to None. This setting can be used when you want to sort using the column headers, disable the selection operation, or any other customizations.