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

Column Autosizing (functionality and a possible bug)

Thread ID:





84826 Jul 2,2009 08:45 PM UTC Jul 3,2009 01:24 PM UTC WPF 2
Tags: GridControl
Administrator [Syncfusion]
Asked On July 2, 2009 08:45 PM UTC

I am using version of the WPF Grid. I have been requested to add some functionality to our grids. Also, a possible bug has been found.

1. Have the ability to double-click on the column resizer to get the corresponding column to automatically size to the optimum width. Is there a flag I can set or an event I can attach to accomplish this?

2. The users are complaining that the default autosizing for the columns allows for too much padding. What properties can I work with to get the padding minimized? They want the column widths to be completely "snug" with the data and no extra space should be to either side of the widest data in the column.

Bug: When manually resizing a column the users sometimes find that the column does not stop resizing after the mouse button is lifted. The column will continue to resize until the mouse button is clicked somewhere in the grid again.

Thank you.

Administrator [Syncfusion]
Replied On July 2, 2009 08:52 PM UTC

Oh, I forgot to mention previously that I am using the GridControl control not the newer GridDataControl control.

Mohamed Suhaib Fahad A. [Syncfusion]
Replied On July 3, 2009 01:24 PM UTC

Hi David,

Thanks for the details.

1) You could listen to the ResizingColumns event to cancel the default resizing and auto-size it through a method call,

void grid_ResizingColumns(object sender, Syncfusion.Windows.Controls.Grid.GridResizingColumnsEventArgs args)
if (args.Reason == Syncfusion.Windows.Controls.Grid.GridResizeCellsReason.DoubleClick)
args.AllowResize = false;
this.grid.Model.ResizeColumnsToFit(args.Columns, GridResizeToFitOptions.None);

The ResizeColumnsToFit would do calculate the optimal width and adjust the width.

2) There is a small padding of value 2 is added to each cell by default, this is because when you go into the edit mode the TextBox will occupy an extra space when it comes into focus. And when the text is drawn it doesn't include this padding values. Can you please send me a screenshot of the padding that you are mentioning here.

3) I do not see this issue with the older or the latest version, I would like to have a reproducing sample or video. This would be of great help in quickly identifying the issue.

We also have fixed up some major internal issues, So you may want to try out the Vol3 release when it is out over the coming weeks.

Please let me know if you need any more details.

Grid.WPF Team
Syncfusion Inc.,


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