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

All complexity of semi-transparent selection and frame control are implemented in .Net Grid, and 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 enable more user-friendly selection method. To initiate this selection mode you have to click left mouse button with the cursor over rows in row selector area or over an empty area beyond the last visible row of the grid. 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 multiple row selection is on.

Key shortcuts

The grid may have multiple selected rows, but only one focused row, i.e. selection is a property of the row, while focus is a property of the grid. 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 clickFocusing and selecting a row
Ctrl + left clickFocusing a row, inverting selection
Shift + left clickFocusing a row, selection of all rows between the previously focused row and the new focused row
EscapeRemoving selection and focus
Ctrl + ASelection of all content
Moving the cursor with left mouse button pressedLasso selection – selection of content in a rectangular area determined by beginning of lasso operation and current cursor position.
Shift + Moving the cursor with left mouse button pressedLasso selection – selection of content in a rectangular area determined by the beginning of lasso operation and current cursor position. Previous selection is preserved.
Key Up/DownFocus move. Selects the newly focused row.
Key PageUp /PageDownSelects and focuses a row that is one page above or below the previously focused row.
Home/EndSelects first or last row in the grid.
Shift + Key Up / Down / PageUp / PageDown / Home / EndFocuses a new row and selects all rows between the last focused row and the new focus.
Ctrl + Key Up / Down / PageUp / PageDown / Home / EndJust moves the focus without changing selection.
Key rightMoving to the last child, or if none is available, to the next row selecting it.
Key leftMoving to the first child, or if none is available, to the previous row selecting it.