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
close icon

Stop Grid from shrinking

How do you stop a grid control from shrinking to fit the data. I have a grid with say only three rows of data and I want it to still fill the whole space it was given in the designer, what property do I have to set so it will.

3 Replies

AD Administrator Syncfusion Team May 24, 2004 03:01 PM UTC

Currently, there is no property that will give you this behavior. But you can handle an event, Model.QueryColWidth and provide the colwidths dynamically there.
this.gridDataBoundGrid1.Model.QueryColWidth += new GridRowColSizeEventHandler(grid_QueryColWidth);

private void grid_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
	if(e.Index == this.gridDataBoundGrid1.Model.ColCount)
	{
		e.Size = this.gridDataBoundGrid1.ClientSize.Width - this.gridDataBoundGrid1.Model.ColWidths.GetTotal(0, this.gridDataBoundGrid1.Model.ColCount-1);
		e.Handled = true;
	}
} 


AD Administrator Syncfusion Team May 24, 2004 04:49 PM UTC

That doesn''t help with the height of the control. My main problem is I have a bunch of grids on a form all lined up nice and neat (with enough room to hold 15+ rows), however when there is a grid that only has 3 rows it makes the form look out of sync since the control gets shrunk.


AD Administrator Syncfusion Team May 24, 2004 06:56 PM UTC

I am sorry, I misread and thought you wanted to expand columns to fill the clientarea. You can have the grid display empty rows by setting this.gridControl1.Model.Options.DisplayEmptyRows = true; Or, you can use the code above (with the right column switch for the last row and ColWidths switched to RowHeights to have a single big row at the bottom.

Loader.
Live Chat Icon For mobile
Up arrow icon