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

howto:? have the last column size itself to the end of the grid.

How can the comments column be sized to the edge of the grid without getting the scrollbars to show up and to it vertically autosize with the text. What is the best way to accomplish this TIA, Peter

1 Reply

AD Administrator Syncfusion Team January 4, 2004 08:34 AM UTC

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...

//the handler
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;

Live Chat Icon For mobile
Up arrow icon