$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView .NET WinForms Control
Grid rows and cells selection in C# from data grid in Windows Forms applications
Home > WinForms UI Controls > User Manual > Grid Rows and Cells Selection in C#

Data Grid Rows and Cells Selection in C#.NET

The KetticGridView also allows the end users to select a single row or cell as well as multiple rows and cells at a time from the data that are shown in grid. UI designers can easily customize the GridView rows and cells selection manually for their C# Windows Forms application. The rows and cells selections allow users to perform selections like, select a single row, select multiple rows, select a single cell, and select multiple cells.

How to Select a Single Row in GridView

The GridView C#.NET component allows the users perform a single row selection in GridView. To achieve this, we need to change the value of the IsSelected property to True. The simple C# code snippet below shows how to enables the property.

ketticGridView1.Rows[2].IsSelected = true;
It is also possible to achieve this by selecting a single grid row to make it current with the C# code below. The two approaches can add the grid rows to the GridView.SelectedRows collection.

ketticGridView1.Rows[2].IsCurrent = true;

How to Select Multiple Grid Rows

The GridView C#.NET component allows the users perform multiple rows selection in GridView. To achieve this, we need to change the value of the IsSelected property to True. The C# code below shows how to select multiple grid rows.

ketticGridView1.ClearSelection();
ketticGridView1.MultipleSelect = true;
ketticGridView1.SelectMode = Kettic.WinForms.UI.GridViewSelectMode.SelectFullRows;
ketticGridView1.Rows[0].IsSelected = true;
ketticGridView1.Rows[4].IsSelected = true;
ketticGridView1.Rows[6].IsSelected = true;
ketticGridView1.Rows[9].IsSelected = true;
The above C# code will add the four grid rows to the SelectedRows collection in GridView. To access the instances of the grid rows selected, we can use the simple C# code as following.

GridViewRowInformation selectedRow = ketticGridView1.SelectedRows[0];

How to Select a Single Grid Cell

The GridView C#.NET component applies the same approach of a single row selection to select cells in GridView. Firstly we need change the value of the IsSelected property to True. And then use the C# code below to select a single grid cell. The grid cell that has been chosen will be added to the GridView.SelectedCells collection.

ketticGridView1.ClearSelection();
ketticGridView1.SelectionMode = Kettic.WinForms.UI.GridViewSelectMode.SelectCell;
ketticGridView1.Rows[1].Cells[3].IsSelected = true;

How to Select Multiple Cells in GridView

To perform multiple cells selection in GridView, we need change the value of the IsSelected property of to True for all grid cells that will be selected. The C# code below shows how to enable the property to them.

ketticGridView1.MultiSelect = true;
ketticGridView1.SelectionMode = Kettic.WinForms.UI.GridViewSelectMode.SelectCell;
ketticGridView1.Rows[0].Cells[0].IsSelected = true;
ketticGridView1.Rows[3].Cells[4].IsSelected = true;
ketticGridView1.Rows[5].Cells[6].IsSelected = true;
ketticGridView1.Rows[6].Cells[8].IsSelected = true;
The above C# code will add the four grid cells to the SelectedCells collection in GridView. To access the instances of the grid cells selected, we can use the simple C# code as following.

GridViewCellInformation selectedCell = ketticGridView1.SelectedCells[0];
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls