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.
Unfortunately, activation email could not send to your email. Please try again.

HOWTO: Stretch grid to Fit?

Thread ID:

Created:

Updated:

Platform:

Replies:

26694 Mar 30,2005 06:04 AM Mar 30,2005 09:41 AM Windows Forms 1
loading
Tags: GridControl
Alex
Asked On March 30, 2005 06:04 AM

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

Administrator [Syncfusion]
Replied On March 30, 2005 09:41 AM

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 int SCROLLBARWIDTH;

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) 
			? SCROLLBARWIDTH :0;
		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)
{
	this.gridGroupingControl1.Refresh();
}

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.

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.

;