Articles in this section

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

Change the column styles


You need to get the TableDescriptors for the parent table, child table, and grandchild table from the
WinForms GridGroupingControl and set the needed column properties like BackColorTextColorWidth, etc. for each table through the GridColumnDescriptor.

 

//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;
'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)
Access denied
Access denied