Category / Section
How to get the current record when clicking the push button in cell selection mode in WinForms GridGroupingControl?
1 min read
Selection mode
By default, the current record of the GridGroupingControl cannot be obtained when clicking the Push button in cell-based selection mode (using the AllowSelection property). The record can be obtained by using the TableControlPushButtonClick event and TableCellIdentity property.
C#
this.gridGroupingControl1.TableControlPushButtonClick += GridGroupingControl1_TableControlPushButtonClick; private void GridGroupingControl1_TableControlPushButtonClick(object sender,GridTableControlCellPushButtonClickEventArgs e) { GridTableCellStyleInfo style =this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); Record record = style.TableCellIdentity.DisplayElement.GetRecord(); if (record != null) { var value = record.GetValue("Name"); } }
VB
AddHandler Me.gridGroupingControl1.TableControlPushButtonClick, AddressOf GridGroupingControl1_TableControlPushButtonClick Private Sub GridGroupingControl1_TableControlPushButtonClick(ByVal sender As Object, ByVal e As GridTableControlCellPushButtonClickEventArgs) Dim style As GridTableCellStyleInfo =Me.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex) Dim record As Record = style.TableCellIdentity.DisplayElement.GetRecord() If record IsNot Nothing Then Dim value = record.GetValue("Name") End If End Sub
Sample links: