AD
Administrator
Syncfusion Team
August 4, 2003 05:18 AM UTC
If you are using a GridDataBoundGrid, the default behavior is to size columns based on the headertext. To turn off this default behavior so you can explicitly size the columns differently, you must set:
this.grid.AllowResieToFit = false;
Then to actually cause the column widths to rezie to to the text, you call this.grid.Model.Cols.ResizeToFit, passing in the range you want to resize, as well as options like whether to include the headers in teh resizing, or to allow the colsize to shrink.
this.grid.Model.Cols.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);
will resize everything. Please note that is you have many, many rows, this may take some time, and you might want to just resize teh visible rows:
Me.Grid.Model.RowHeights.ResizeToFit(GridRangeInfo.Rows(Me.GridDetail.TopRowIndex, Me.Grid.ViewLayout.LastVisibleRow), GridResizeToFitOptions.None)