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

HOWTO: Stretch grid to Fit?

Hi, How can I stretch my Grid to fit The width of my container. If I have a Grid with only two small columns I want the grid to stretch the last column to fill up the empty space.Im using the GridGroupingControl version 3.xxxx Regards AL

1 Reply

AD Administrator Syncfusion Team March 30, 2005 02:41 PM UTC

Try this code. //in form.Load this.gridGroupingControl1.SizeChanged += new EventHandler(gridGroupingControl1_SizeChanged); this.gridGroupingControl1.TableControl.Model.QueryColWidth += new GridRowColSizeEventHandler(grid_QueryColWidth); this.SCROLLBARWIDTH = SystemInformation.VerticalScrollBarWidth;
//the event handlers

private void grid_QueryColWidth(object sender, GridRowColSizeEventArgs e)
	int last = this.gridGroupingControl1.TableDescriptor.VisibleColumns.Count;
	if(e.Index == last + this.gridGroupingControl1.TableDescriptor.GroupedColumns.Count)
		int vscrollwidth = ((this.gridGroupingControl1.TableControl.Model.RowHeights.GetTotal(0, this.gridGroupingControl1.TableControl.Model.RowCount)  
			+  this.gridGroupingControl1.TableOptions.CaptionRowHeight)
			> this.gridGroupingControl1.ClientSize.Height) 
		e.Size = this.gridGroupingControl1.ClientSize.Width - 
			this.gridGroupingControl1.TableControl.Model.ColWidths.GetTotal(0, e.Index - 1)
			- vscrollwidth;
		e.Handled = true;

private void gridGroupingControl1_SizeChanged(object sender, EventArgs e)

Live Chat Icon For mobile
Up arrow icon