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

Change the column width in GridDataBoundGrid

Thread ID:





7395 Sep 24,2003 03:55 AM UTC Sep 24,2003 08:52 AM UTC WinForms 2
Tags: GridControl
Asked On September 24, 2003 03:55 AM UTC

First in my application I don't need to bound the grid to any DataSource but at some point when I do that, the columns width is not reflecting the text length in the cells(I need some AutoResize). Thank you, Ionut Balas

Administrator [Syncfusion]
Replied On September 24, 2003 08:40 AM UTC

If you want to autosize the columns to fit the text, you can call the ResizeToFit member of the ColWidths class. You can pass in any range you want to resize. This code does the whole table. grid.ColWidths.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders); - Or - you could pass in only the visible cells range ( this.gridDataBoundGrid1.ViewLayout.VisibleCellsRange) You might also need to set gridDataBoundGrid1.AllowResizeToFit = False. If AllowResizeToFit is true, then the grid tries to autosize the columns based on the with of their header texts. This might interfere with the explicit sizing that you are trying to do. Stefan

Replied On September 24, 2003 08:52 AM UTC

Thank you, 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