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

How to resize column to best fit when double click at column header?

Thread ID:

Created:

Updated:

Platform:

Replies:

32661 Aug 5,2005 07:42 AM UTC Aug 5,2005 10:16 AM UTC WinForms 1
loading
Tags: GridControl
William Ng Cheng Piaw
Asked On August 5, 2005 07:42 AM UTC

When double click on the line between 2 columns at the column header, the column will resize to a default size. How do I make it such that it will resize to the best fit (longest content in the column ) like in excel? Thanks.

Administrator [Syncfusion]
Replied On August 5, 2005 10:16 AM UTC

There is no property that does this, but you can do it handling the ResizingCols event.
private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
	if(e.Reason == GridResizeCellsReason.DoubleClick)
	{
		this.gridControl1.ColWidths.ResizeToFit(e.Columns, GridResizeToFitOptions.IncludeHeaders);
		e.Cancel = 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

;