This topic contains the following sections.

Row selection

Wpf GridControl row selection is a very important feature that determines how user-friendly is a component. In existing grids selection is usually implemented by inversion of background cell colors or by painting cells with a predefined color. It is the simplest implementation, however in this case the end user may have troubles understanding the information. With such approach important information can become obscured and unavailable for selected rows. The selection system in Wpf GridControl has been revamped to make it most user-friendly, to provide the most convenient API and to ensure component performance. When Wpf GridControl selects rows, it mixes selection colors with row background color and displays a border frame around selection. The border frame is not displayed between adjacent selected rows. Such approach is the most intuitive for end user and preserves all information displayed in the grid.

Wpf GridControl semi-transparent selection

All complexities of semi-transparent selection and border frame control are implemented in Wpf Grid, while the programmer gets a simple and convenient API to control selection.

C# Copy imageCopy
//Select row in the grid
row.Selected = true;

//Iterate selection
foreach (Row selectedRow in grid.Selection)
{
    //Do something...
}

Lasso selection

An additional lasso selection feature has been implemented to make the selection method even more user-friendly. To initiate this selection mode you have to move the cursor over rows in row selector area or over an empty area beyond the last visible row of the grid and click the left mouse button. When the cursor is moved with left mouse button pressed, a rectangular area appears. All rows in this area become selected. Lasso selection works only when selection of multiple rows is enabled.

Wpf GridControl lasso selection

Key shortcuts

The grid may have multiple selected rows, but only one focused row, i.e. selection is a row property, while focus is a grid property. The grid provides standard user-friendly tools to control selection and focus. Rows are selected by left-clicking grid cells, area above row selector or location above the area to the right of the last visible column. Clicking a row selects it and puts it in focus. Clicking a row with different keys pressed may have various effects. The most frequent key shortcuts for the grid are listed below.

Key shortcutDescription
Left clickFocuses and selects a row
Ctrl + left clickFocuses a row, inverts selection
Shift + left clickFocuses a row, selects of all rows between the previously focused row and the new focused row
EscapeRemoves selection and focus
Ctrl + ASelects of all content
Moving the cursor with left mouse button pressedLasso selection – selection of content in a rectangular area determined by the starting point of lasso operation and the current cursor position.
Shift + Moving the cursor with left mouse button pressedLasso selection – selection of content in a rectangular area determined by the starting point of lasso operation and the current cursor position. Previous selection is preserved.
Up/Down arrowFocus move. Selects the newly focused row.
PageUp /PageDownSelects and focuses a row that is one page above or below the previously focused row.
Home/EndSelects the first or the last row of the grid.
Shift + Up / Down arrow / PageUp / PageDown / Home / EndFocuses a new row and selects all rows between the last focused row and the new focused row.
Ctrl + Up / Down arrow / PageUp / PageDown / Home / EndMoves the focus without changing selection.
Right arrowMoves to the last child or (if no last child is available) to the next row selecting it.
Left arrowMoves to the first child or (if no first child is available) to the previous row selecting it.