Virtual Grid - auto-size columns

We have a virtual grid that is used for scrolling over a large set of data. How can we make the columns auto-size themselves based on their caption?


6 Replies

RC Rajadurai C Syncfusion Team November 24, 2008 06:25 AM UTC

Hi Joelr,

Thanks for your interest in Syncfusion products.

For a virtual grid, you can achieve the column width based on the text length in cells through the ResizeToFit property.


void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.Style.CellType == "TextBox")
this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(e.ColIndex), GridResizeToFitOptions.NoShrinkSize);
}


Regards,
Rajadurai



SM Steven Mohnkern June 3, 2009 08:41 PM UTC

Is there a similar way to auto size the height of rows?


JJ Jisha Joy Syncfusion Team June 4, 2009 09:29 AM UTC

Hi Steve,

Please see the following code for code for auto size the height of rows.

this.gridListControl1.Grid.RowHeights.ResizeToFit(GridRangeInfo.Cells(1, 1, row, col));

Please let me know if this helps.

Regards,
Jisha


SM Steven Mohnkern June 4, 2009 12:53 PM UTC

Does this work for GridGroupingControl as well?


JJ Jisha Joy Syncfusion Team June 5, 2009 08:40 AM UTC

Hi,

For gridgrouping control you could access the property using the TableModel. Please see the code:

this.gridGroupingControl1.TableModel.RowHeights.ResizeToFit(GridRangeInfo.Table());

Please let me know if this helps.

Regards,
Jisha


JJ Jisha Joy Syncfusion Team June 5, 2009 08:43 AM UTC

Hi,

For gridgrouping control you could access the property using the TableModel. Please see the code:

this.gridGroupingControl1.TableModel.RowHeights.ResizeToFit(GridRangeInfo.Table());

Please let me know if this helps.

Regards,
Jisha

Loader.
Up arrow icon