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

Resize grid to window size

The grid control is the only control I have on the form. I want the grid control to fill the form. I have set dock style to fill but when I run it doesn''t resize to fill the window. What else do I have to do to make a grid fill the form?

3 Replies

AD Administrator Syncfusion Team February 19, 2004 11:55 AM UTC

Docking the grid in a form will only change the grid''s clientarea/bounds as you size the form. If you want the column widths and row heights to change so the whole client area of the grid is occupied by grid cells, then you should handle the QueryRowHeights and QueryColWidths events and dynamically set the height/width of the requested row/column based on the clientsize. Take a look at this sample, Syncfusion\Essential Suite\Grid\Samples\DataBound\GridDataBoundImageCell. It shows the grid dynamically changing colwidths/rowheights as you size the form.


AD Administrator Syncfusion Team February 23, 2004 12:56 AM UTC

Thanks for the pointer. This helped a lot. The only issue with column resizing I haven''t been able to get working is by default a column can be hidden from view by dragging its width to 0, how can I prevent this but still let the user resize a column? I would also not like them to be able to resize a column so that the scroll bar would have to be used to view the column. thanks >Docking the grid in a form will only change the grid''s clientarea/bounds as you size the form. If you want the column widths and row heights to change so the whole client area of the grid is occupied by grid cells, then you should handle the QueryRowHeights and QueryColWidths events and dynamically set the height/width of the requested row/column based on the clientsize. > >Take a look at this sample, Syncfusion\Essential Suite\Grid\Samples\DataBound\GridDataBoundImageCell. It shows the grid dynamically changing colwidths/rowheights as you size the form.


AD Administrator Syncfusion Team February 23, 2004 05:33 AM UTC

If you want to prevent your user from sizing a column to width zero, then you can cancel the resize by handling the RsizingColumns event.
private void gridDataBoundGrid1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
	if(e.Reason == GridResizeCellsReason.MouseUp && e.Width < 1)
		e.Cancel = true;
}	

Loader.
Live Chat Icon For mobile
Up arrow icon