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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Auto-adjust column width in nested tables of GridGroupingControl

Thread ID:





72840 Apr 8,2008 12:29 PM UTC Apr 23,2008 10:34 PM UTC WinForms 4
Tags: GridControl
Asked On April 8, 2008 12:29 PM UTC

Hi all,

I have an object which contains a list of children (of the same type). In the main class i have a list of objects of this type and I have binded this to a grid grouping control. I think the control understand the relation between these objects and automatically displays the children of the parent object in a hierarchical manner.

My question is how do i auto-adjust the width of all columns to fill the available space? I have got this working for the root level but i dont really know how to do that for the levels beyond that.


Replied On April 11, 2008 09:44 AM UTC

Actually I have sorted this out but i realized that the border between the parent cells and the nested cells is not exactly aligned. I want the parent cells with the children cells to be exactly the same in terms of positioning and width.


haneefm [Syncfusion]
Replied On April 12, 2008 12:19 AM UTC

Hi John,

If you want to align the ParentTable and ChildTable properly, you need to use the TrackWidhtofParentColumn property. You can use the below code snippet to resolve this issue.

private void SetTrackWidthOfParentColumn( GridTableDescriptor descriptor)
if (descriptor == null) return;

foreach (GridRelationDescriptor relationDescriptor in descriptor.Relations)
for (int n = 0; n < relationDescriptor.ChildTableDescriptor.VisibleColumns.Count ; n++)
relationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = relationDescriptor.ParentTableDescriptor.Columns[n].Name;

For call the above method, please use this


Best regards,

Replied On April 14, 2008 08:16 AM UTC

Works great but now the grid doesnt consume all the client area cause i had to remove the QueryColWidth handler to make the column alignment work. Is there any way to combine both? thx

haneefm [Syncfusion]
Replied On April 23, 2008 10:34 PM UTC

Hi JohnFish,

You can set the Colwidth of the last column by using the below code snippet to fill the client area. Below are the codes:

int width = this.gridGroupingControl1.TableModel.ColWidths.GetTotal(0, this.gridGroupingControl1.TableModel.ColCount - 2);
int clientwidth = this.gridGroupingControl1.ClientRectangle.Width;
this.gridGroupingControl1.TableDescriptor.Columns[ this.gridGroupingControl1.TableDescriptor.Columns.Count - 1].Widht = clientwidht - width;

Best regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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