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

Dynamic column widths

Thread ID:





11464 Mar 6,2004 03:33 PM UTC Mar 13,2004 11:01 AM UTC WinForms 3
Tags: GridControl
Ken Law
Asked On March 6, 2004 03:33 PM UTC

I''d like to dynamically set the initial width of columns in a GridDataBoundGrid based on the width of the header text OR the width of the longest string in the source data , whichever is longest. The grid is bound to a DataTable. Any suggestions?

Administrator [Syncfusion]
Replied On March 6, 2004 06:17 PM UTC

Try this after you have set the DataSource: //turn off grid''s default sizing this.grid.AllowResizeToFit = false; //size things yourself this.grid.Model.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);

Ken Law
Replied On March 13, 2004 09:49 AM UTC

Thanks - that works very well for my program. Why is it necessary to set AllowResizeToFit = false? The call to ResizeToFit seems to work when this is set to true.

Administrator [Syncfusion]
Replied On March 13, 2004 11:01 AM UTC

By default, the GridDataBoundGrid tries to autosize the columns based on headertext. The AllowResizeToFit = false turns off this default sizing. If you do not turn it off, the grid trying to size things based on headertext can step on any explicit sizing you try to do.


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