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

Column Autosizing (functionality and a possible bug)

I am using version 7.2.0.20 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.

2 Replies

AD Administrator Syncfusion Team 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.


MS Mohamed Suhaib Fahad A. Syncfusion Team 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.

Thanks,
Fahad
Grid.WPF Team
Syncfusion Inc.,

Loader.
Live Chat Icon For mobile
Up arrow icon