)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to retrieve current record on cell double click in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: February 22, 2018 |
Last Revised Date: December 23, 2019

CellDoubleClick event

The TableControlCellDoubleClick/TableControl.CellDoubleClick event can be used to notify whenever the double click on a cell is occurred. For further information about the event, TableControlCellDoubleClick .

 

In order to retrieve the current selected record when the cell double click is occurred, the SelectedRecords collection can be used to retrieved record and this can be available from the TableControl of the event args. To get the values of particular column, the GetValue() method of the record can be used.

 

Using TableControlCellDoubleClick event

C#

//Event triggering
this.gridGroupingControl1.TableControlCellDoubleClick += GridGroupingControl1_TableControlCellDoubleClick;
 
//Event customization
private void GridGroupingControl1_TableControlCellDoubleClick(object sender, GridTableControlCellClickEventArgs e)
{
    if (e.TableControl.Table.SelectedRecords.Count > 0)
    {
        Record selectedRecord;
        if (gridGroupingControl1.TableOptions.ListBoxSelectionMode == SelectionMode.One)
        {
            //To get the selected record when selection mode is one
            selectedRecord = e.TableControl.Table.SelectedRecords[0].Record;
        }
        else
        {
            //To get the selected record for other selection modes
            int count = e.TableControl.Table.SelectedRecords.Count;
            selectedRecord = e.TableControl.Table.SelectedRecords[count - 1].Record;
        }
        //To show the new form
        DisplayForm displayForm = new DisplayForm(selectedRecord);
        displayForm.Show();
    }
}

 

VB

'Event triggering
AddHandler Me.gridGroupingControl1.TableControlCellDoubleClick, AddressOf GridGroupingControl1_TableControlCellDoubleClick
 
Private Sub GridGroupingControl1_TableControlCellDoubleClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs)
 If e.TableControl.Table.SelectedRecords.Count > 0 Then
  Dim selectedRecord As Record
        If gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One Then
            'To get the selected record when selection mode Is one
            selectedRecord = e.TableControl.Table.SelectedRecords(0).Record
        Else
            'To get the selected record for other selection modes
            Dim count As Integer = e.TableControl.Table.SelectedRecords.Count
            selectedRecord = e.TableControl.Table.SelectedRecords(count - 1).Record
        End If
        'To show the New form
        Dim displayForm As New DisplayForm(selectedRecord)
  displayForm.Show()
 End If
End Sub

 

Using TableControl.CellDoubleClick event

C#

//Event triggering
this.gridGroupingControl1.TableControl.CellDoubleClick += TableControl_CellDoubleClick;
 
//Event customization
private void TableControl_CellDoubleClick(object sender, GridCellClickEventArgs e)
{
    if (e.TableControl.Table.SelectedRecords.Count > 0)
    {
        Record selectedRecord;
        if (gridGroupingControl1.TableOptions.ListBoxSelectionMode == SelectionMode.One)
        {
            //To get the selected record when selection mode is one
            selectedRecord = gridGroupingControl1.Table.SelectedRecords[0].Record;
        }
        else
        {
            //To get the selected record for other selection modes
            int count = gridGroupingControl1.Table.SelectedRecords.Count;
            selectedRecord = gridGroupingControl1.Table.SelectedRecords[count - 1].Record;
        }
        //To show the new form
        DisplayForm displayForm = new DisplayForm(selectedRecord);
        displayForm.Show();
    }
}

 

VB

'Event triggering
AddHandler Me.gridGroupingControl1.TableControl.CellDoubleClick, AddressOf TableControl_CellDoubleClick
 
'Event customization
Private Sub TableControl_CellDoubleClick (ByVal sender As Object, ByVal e As GridCellClickEventArgs)
If e.TableControl.Table.SelectedRecords.Count > 0 Then
  Dim selectedRecord As Record
        If gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One Then
            'To get the selected record when selection mode Is one
            selectedRecord = gridGroupingControl1.Table.SelectedRecords(0).Record
        Else
            'To get the selected record for other selection modes
            Dim count As Integer gridGroupingControl1.Table.SelectedRecords.Count
            selectedRecord = gridGroupingControl1.Table.SelectedRecords(count - 1).Record
        End If
        'To show the New form
        Dim displayForm As New DisplayForm(selectedRecord)
  displayForm.Show()
 End If
End Sub

 

Screenshot

Shows the order details while double click on a cell

 

Samples:

C#: RecordOnCellDoubleClick_CS

VB: RecordOnCellDoubleClick_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon