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

Column Width and ExpandAllGroups

Thread ID:





78444 Dec 12,2008 06:21 PM UTC Jan 6,2009 04:55 AM UTC ASP.NET Web Forms (Classic) 3
Tags: GridGroupingControl
Saurabh Srivastava
Asked On December 12, 2008 06:21 PM UTC


I am trying to fix up the width of columns. My columns are being generated at runtime. Hence, on page load if I do grid.tabledescriptor.columns[0].width=100
it gives me a null reference exception. What is another way of doing it?

Also, I have set the ExpandAllGroups on the page load but it doesnt seem to work. I am using the latest version for Syncfusion (6.402.0.15).

Please help.

Saurabh Srivastava
Replied On December 13, 2008 11:36 AM UTC


I am able to refernce columns now. I was not binding at runtime and that was the reason why it was not accessible. The ExpandAllGroups() now works fine. But I am still not able to alter the width of the columns. I am applying a custom CSS on the grid. Is that the reason for it?

Rajarajeswari S [Syncfusion]
Replied On December 15, 2008 06:21 AM UTC

Hi Saurabh,

I am afraid that I am not able to reproduce the issue, that you have mentioned here. Applying Custom CSS doesn’t affect of setting column width. Please refer the below sample where I have followed the below things:

1. Created Grid, and applied custom CSS.
2. Creating a new column dynamically.
3. Setting width for the dynamically created column.
4. The width is applied to the column properly.

Please refer the below code snippet which illustrates this:

protected void Button1_Click(object sender, EventArgs e)
GridColumnDescriptor gcd = this.GridGroupingControl1.TableDescriptor.GetColumnDescriptor("NewColumn");
gcd.Width = 300;

Please refer the sample from the below link, which illustrates the above:


Please let me know if you have any other concerns.


Saurabh Srivastava
Replied On January 6, 2009 04:55 AM UTC


I tried all possible combinations to set the column width, but none seems to work.

I am creating the columns dynamically by a stored procedure.

Following are the methods are I tried:

this.GridGroupingControl1.TableDescriptor.Columns[1].MaxLength = 10;

for (int i = 0; i < this.GridGroupingControl1.TableDescriptor.Columns.Count; i++) this.GridGroupingControl1.TableDescriptor.Columns[i].Width = 20;

this.GridGroupingControl1.TableDescriptor.Columns[1].MaxLength = 10; this.GridGroupingControl1.TableOptions.ColumnsMaxLengthStrategy = GridColumnsMaxLengthStrategy.MaxLengthSummary;

this.GridGroupingControl1.TableOptions.DefaultColumnWidth = 10;

GridColumnDescriptor gcd = this.GridGroupingControl1.TableDescriptor.GetColumnDescriptor("myColumn");
gcd.Width = 20;

This is my design time defn of Gridgrouping control:
ShowGroupDropArea="False" BorderCollapse="Separate" OnQueryCellStyleInfo="cControl_QueryCellStyleInfo" OnQueryCoveredRange="cControl_QueryCoveredRange" EnablePostbacks="false" TableDescriptor-AllowEdit="false" TableOptions-AllowDragColumns="false" Width="400"
TableOptions-AllowSortColumns="false" ReadOnly="true" TableDescriptor-AllowColumnResize="false">

Please advise.



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

This page will automatically be redirected to the 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