ADAdministrator Syncfusion Team January 4, 2004 03:34 AM
You can handle auto sizing the right-most column to fit the grid''s clientarea by handling the Model.QueryColWidth event, and dynamically setting the required width there. You should also turn off the SmoothControlResize property to avoid some painting problems when sizing.
To autosize row heights, you would call the Model.RowHeights.ResizeToFit method. (Or, if you want the height to adjust as your user types into a cell, then you would also have to set the GridBoundColumn.StyleInfo. AutoSize property for the column.)
//code in FormLoad...
this.grid.Model.QueryColWidth += new GridRowColSizeEventHandler(gridModel_QueryColWidths);
this.grid.SmoothControlResize = false;
//size rowheights to fit in col 4...
private void gridModel_QueryColWidths(object sender, GridRowColSizeEventArgs e)
int nCols = this.grid.Model.ColCount;
if(e.Index == nCols)
e.Size = this.grid.ClientSize.Width
- this.grid.Model.ColWidths.GetTotal(0, nCols - 1);
e.Handled = true;