)
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 set column style properties for the nested tables in the WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: February 12, 2020

Change the column styles

You need to get the TableDescriptors for the parent table, child table, and grandchild table from the GroupingControl and set the needed column properties like BackColor, TextColor, Width, etc. for each table through the GridColumnDescriptor.

C#

//Use the tabledesciptor to set the properties.
//Sets some parent properties.
GridTableDescriptor parentTD = (GridTableDescriptor)engine.TableDescriptor;
//Sets backcolor to the column.
parentTD.Columns["ParentName"].Appearance.AnyCell.BackColor = Color.LightGoldenrodYellow;
//Sets width of the column.
parentTD.Columns["ParentName"].Width = 120;
//Sets some child properties.
GridTableDescriptor childTD = parentTD.Relations["ParentToChild"].ChildTableDescriptor;
//Sets backcolor to the column.
childTD.Columns["Name"].Appearance.AnyCell.BackColor = Color.LightPink;
//Sets width of the column.
childTD.Columns["Name"].Width = 160;
//Sets some grandchild properties.
GridTableDescriptor grandChildTD = childTD.Relations["ChildToGrandChild"].ChildTableDescriptor;
//Sets backcolor to the column.
grandChildTD.Columns["Name"].Appearance.AnyCell.BackColor = Color.Red;
//Sets width of the column.
grandChildTD.Columns["Name"].Width = 190;

VB

'Use the tabledesciptor to set the properties.
'Sets some parent properties.
Dim parentTD As GridTableDescriptor = CType(engine.TableDescriptor, GridTableDescriptor)
'Sets backcolor to the column.
parentTD.Columns("ParentName").Appearance.AnyCell.BackColor = Color.LightGoldenrodYellow
'Sets width of the column.
parentTD.Columns("ParentName").Width = 120
'Sets some child properties.
Dim childTD As GridTableDescriptor = parentTD.Relations("ParentToChild").ChildTableDescriptor
'Sets backcolor to the column.
childTD.Columns("Name").Appearance.AnyCell.BackColor = Color.LightPink
'Sets width of the column.
childTD.Columns("Name").Width = 160
'Sets some grandchild properties.
Dim grandChildTD As GridTableDescriptor = childTD.Relations("ChildToGrandChild").ChildTableDescriptor
'Sets backcolor to the column.
grandChildTD.Columns("Name").Appearance.AnyCell.BackColor = Color.Red
'Sets width of the column.
grandChildTD.Columns("Name").Width = 190

After applying the properties, the grid looks like the following screenshot.

Column styles to a particular column

Figure 1: Column styles to a particular column

Samples:

C#: Column_styles_for_NestedTables

VB: Column_styles_for_NestedTables

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