Articles in this section

How to get the current cell of the nested ChildTable in WinForms GridGroupingControl?

Show record and column name


The usual TableControl.CurrentCell property does not give the exact CurrentCell when the CurrentCell is in the nested table in WinForms GridGroupingControl . To get the CurrentCell value from the nested tables, you can use the following methods:

 

1. By using GetNestedCurrentCell

2. By using CurrentElement.


By using the GetNestedCurrentCell:

 

By using the GetNestedCurrentCell method, you get the CurrentCell directly from anywhere in the nested table. Refer to the following code to get the CurrentCell.

 

//Gets the CurrentCell by using the GetNestedCurrentCell().
GridCurrentCell cc = this.gridGroupingControl1.TableControl.GetNestedCurrentCell();
'Gets the CurrentCell by using the GetNestedCurrentCell() .
Dim cc As GridCurrentCell = Me.gridGroupingControl1.TableControl.GetNestedCurrentCell()

By using the CurrentElement:

By using the Table and TableControl properties of the GridGroupingControl that is taken from the CurrentElement, you can get the CurrentCell even when it is in the child table.  Refer to the following code to get the CurrentCell.

void btnGetrecord_Click(object sender, EventArgs e)
{
    //Gets the Current Element.
    Element el = this.gridGroupingControl1.Table.GetInnerMostCurrentElement();
    if (el != null)
    {
        //Gets table from element parenttable.
        GridTable table = el.ParentTable as GridTable;

        //Gets table control by using the table descriptor name. 
        GridTableControl tableControl = this.gridGroupingControl1.GetTableControl (table.TableDescriptor.Name);

        //Gets current cell by using the tablecontrol.
        GridCurrentCell cc = tableControl.CurrentCell;
        Console.WriteLine("Row Column indes by using Currrentelement");
        Console.WriteLine("Row Index"+ cc.RowIndex.ToString());
        Console.WriteLine("Column Index"+ cc.ColIndex.ToString());
    }
}
Private Sub btnGetrecord_Click(ByVal sender As Object, ByVal e As EventArgs)
    'Gets the Current Element.
    Dim el As Element = Me.gridGroupingControl1.Table.GetInnerMostCurrentElement()

    If el IsNot Nothing Then
        'Gets table from element parent table.
        Dim table As GridTable = TryCast(el.ParentTable, GridTable)

        'Gets table control by using the table descriptor name.
        Dim tableControl As GridTableControl = Me.gridGroupingControl1.GetTableControl(table.TableDescriptor.Name)

        'Gets current cell by using table control.
        Dim cc As GridCurrentCell = tableControl.CurrentCell

        Console.WriteLine("Row Column index by using CurrentElement")
        Console.WriteLine("Row Index: " & cc.RowIndex.ToString())
        Console.WriteLine("Column Index: " & cc.ColIndex.ToString())
    End If
End Sub

The following screenshots display Record and Column name displayed on button click.


Show record and column name


Conclusion

I hope you enjoyed learning about how to get the current cell of the nested ChildTable 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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied