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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

9616 Jan 4,2004 05:12 AM UTC Jan 4,2004 08:34 AM UTC WinForms 1
loading
Tags: GridControl
Peter
Asked On January 4, 2004 05:12 AM UTC

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

Administrator [Syncfusion]
Replied On 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...
this.grid.Model.RowHeights.ResizeToFit(GridRangeInfo.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;
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;