Category / Section
How to programmatically select a row in WinForms GridDataBoundGrid?
2 mins read
Selection
By default, the selection can be done in grid by using mouse. In this article, it explains about adding the selection by programmatically for GridControl, GridGroupingControl and GridDataBoundGrid.
1. GridControl
C#
this.gridControl1.Selections.Add(GridRangeInfo.Row(3));
VB
Me.gridControl1.Selections.Add(GridRangeInfo.Row(3))
2. GridGroupingControl
The GridGroupingControl has two kinds of selections. They are
1.Range selection
2.Record selection
Range selections
C#
this.gridGroupingControl1.TableModel.Selections.Add(GridRangeInfo.Row(4));
VB
Me.gridGroupingControl1.TableModel.Selections.Add(GridRangeInfo.Row(4))
Record selection
The record selection can be done by using SetSelected method of Record which needs to be selected.
C#
this.gridGroupingControl1.Table. Recods[0].SetSelected(true);
VB
this.gridGroupingControl1.Table. Recods[0].SetSelected(True)
3. GridDataBoundGrid
Add the row in Selections from GridDataBoundGrid.
C#
this.gridDataBoundGrid1.Selections.Add(GridRangeInfo.Row(2));
VB
Me.gridDataBoundGrid1.Selections.Add(GridRangeInfo.Row(2))
Samples:
C#: Selections
VB: Selections