How to select the row while clicking on checkbox cell in WinForms GridGroupingControl?
Row selection
To select the
row while clicking on the checkbox, the TableControlCheckBoxClick event
can be handled. The SetSelected method can be used to select
or deselect the row.
C#
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
private void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e)
{
style = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
currentRecord = style.TableCellIdentity.DisplayElement.GetRecord();
bool checkStatus = (style.Text == string.Empty || style.Text == "false");
currentRecord.SetSelected(checkStatus);
}AddHandler Me.gridGroupingControl1.TableControlCheckBoxClick, AddressOf gridGroupingControl1_TableControlCheckBoxClick
Private Sub gridGroupingControl1_TableControlCheckBoxClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs)
Dim style As GridTableCellStyleInfo = CType(e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex), GridTableCellStyleInfo)
Dim currentRecord As Record = style.TableCellIdentity.DisplayElement.GetRecord()
Dim checkStatus As Boolean = (style.Text = String.Empty OrElse style.Text = "false")
currentRecord.SetSelected(checkStatus)
End Sub CurrentCellKeyDown event can be used for selecting the particular row by using space key on the checkbox.
C#
this.gridGroupingControl1.TableControlCurrentCellKeyDown += gridGroupingControl1_TableControlCurrentCellKeyDown;
private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
GridStyleInfo style = e.TableControl.CurrentCell.Renderer.CurrentStyle;
// Make a selection while check the checkbox using key navigation
if (e.Inner.KeyCode == Keys.Space && style.CellType == GridCellTypeName.CheckBox)
{
e.TableControl.RaiseCheckBoxClick(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex, MouseEventArgs.Empty as MouseEventArgs);
}
}VB
AddHandler Me.gridGroupingControl1.TableControlCurrentCellKeyDown, AddressOf gridGroupingControl1_TableControlCurrentCellKeyDown
Private Sub gridGroupingControl1_TableControlCurrentCellKeyDown(ByVal sender As Object, ByVal e As GridTableControlKeyEventArgs)
Dim style As GridStyleInfo = e.TableControl.CurrentCell.Renderer.CurrentStyle
' Make a selection while checking the checkbox using key navigation
If e.Inner.KeyCode = Keys.Space AndAlso style.CellType = GridCellTypeName.CheckBox Then
e.TableControl.RaiseCheckBoxClick(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex, CType(MouseEventArgs.Empty, MouseEventArgs))
End If
End Sub The screenshot below illustrates the row selection by using the checkbox.

Samples:
C#: Row selection
VB: Row selection
Conclusion
I hope you
enjoyed learning about how to select the row while clicking on checkbox cell in
WinForms GridGroupingControl.
You can refer to our WinForms GridGroupingControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms GridGroupingControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!