Skip to main content
A newer version of this page is available. .

GridView.SelectCell(Int32, GridColumn) Method

Selects the cell.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v18.2.dll

Declaration

public virtual void SelectCell(
    int rowHandle,
    GridColumn column
)

Parameters

Name Type Description
rowHandle Int32

The cell’s row handle.

column GridColumn

The cell’s column.

Remarks

A cell is located at the specified row and column’s intersection.

The SelectCell method does nothing if multiple cell selection (block selection) is disabled. To ensure that block selection is in effect, use the GridView.IsCellSelect property. To unselect a cell use the GridView.UnselectCell method.

When the selection changes, the ColumnView.SelectionChanged event occurs.

The code sample below illustrates how to select the entire grid column when users hold the CTRL button and click on a column’s header.


gridView1.OptionsSelection.MultiSelect = true;
gridView1.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect;
gridView1.MouseDown += GridView1_MouseDown;

private void GridView1_MouseDown(object sender, MouseEventArgs e)
{
    GridView view = sender as GridView;
    GridViewInfo gridInfo = view.GetViewInfo() as GridViewInfo;
    GridHitInfo hitInfo = view.CalcHitInfo(e.Location);

    if (hitInfo.InColumnPanel && e.Button == System.Windows.Forms.MouseButtons.Left && ModifierKeys == Keys.Control)
    {
        for (int i = 0; i < hitInfo.Column.View.RowCount; i++)
            view.SelectCell(i, hitInfo.Column);
        ((DXMouseEventArgs)e).Handled = true;
    }

}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectCell(Int32, GridColumn) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also