Articles in this section
Category / Section

How to set column style properties for the nested tables in the WinForms GridGroupingControl?

1 min read

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

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