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

Autosizing of columns or rows when double-clicking header edge

Thread ID:





4529 May 16,2003 07:47 PM UTC May 16,2003 08:09 PM UTC WinForms 1
Tags: GridControl
Tom Le Blanc
Asked On May 16, 2003 07:47 PM UTC

When one double-clicks on the right edge of the column header in Excel, that column does a resize to fit so that the longest piece of data in one of the cells is visible. The same thing applies to row heights. And if one selects the entire grid and double-clicks an edge then all the columns and all the rows resize to fit. I’ve found that while this behavior also occurs in the Grid, it is not quite as expected. In most cases it does the opposite. Rather than resizing to fit that long piece of data, it will collapse the column (or row) to some predetermined, smaller width (height). The times I have seen it actually expand a column, said column was already wide enough to display the data but the Grid expanded a little more to give it some nice padding. And there isn’t any expand all functionality [not so much of a problem but I just wanted to note it in this comparison]. So, is there any workaround code to trap for this double-click on column/row header edge event and programmaticly behave like Excel? Or, is this a bug I should report on Direct-Track? Or, all of the above? Thanks, Tom

Administrator [Syncfusion]
Replied On May 16, 2003 08:09 PM UTC

The grids default behavior is to reset the column width or row height back to its original value (as specified with Cols.DefaultSize). There is no property to change this behavior but you can change it by subscribing to the ResizingCols/ResizingRows 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; } } Alternatively, you could do ColWidths.ResizeToFit only for the visible rows. Stefan


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon