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. Image for the cookie policy date

Grid: Autosize during initiaisation

I''ve a problem with autosize feature in colums. When autosize is true, the column resizes perfectly when entering text in cells. So far, so good.

But there are two problems I''ve not found how to solve them:

First: When initializing a group of cells in a column, the column width does not fit to the largest text in that column. It remains at default width until I''m manually adding some text.

Second: The cell width does increase when entering text manually. But when text becomes shorter again, the width does not reduce.

How can I do this? Is Autosize the right feature implementing those things?

Thanks in advance
Andreas

3 Replies

AD Administrator Syncfusion Team September 21, 2006 07:46 AM UTC

Hi Andreas,

1. In the Form Load, call the ResizeToFit() method to make all the column widths get adjusted to its cell contents.

this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);

2. Try the code below in the TableControlCurrentCellChanged event handler to dynamically adjust the column width while entering text.

//
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
this.gridGroupingControl1.TableModel.ColWidths.ResizeToFit(cc.RangeInfo, GridResizeToFitOptions.None);
//

Let me know if this helps for you.
Regards,
Rajagopal


AD Administrator Syncfusion Team September 22, 2006 06:19 AM UTC

That works perfectly!

Many thanks
Andreas


AG Andreas Gfeller September 22, 2006 06:20 AM UTC

That works perfectly!

Many thanks
Andreas

Loader.
Live Chat Icon For mobile
Up arrow icon