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

DataProvider and ResizeToFit

Thread ID:





7970 Oct 15,2003 08:27 PM UTC Oct 16,2003 08:08 AM UTC WinForms 2
Tags: GridControl
Peter Zaborski
Asked On October 15, 2003 08:27 PM UTC

I am using a DataBoundGrid and populating it via the DataProvider property. I've implemented my own data provider. This works fine as far as the grid displaying the correct data values. However, it seems I can't resize the cells (col widths specifically) because if I call grid.Model.ColWidths.ResizeToFit this call gets executed BEFORE the calls for data to the data provider, ie. the grid's cell values are all "" and thus the col widths never get set correctly! Is there a way to use a data provider mechanism to populate the grid and still be able to use the ResizeToFit function? Or is there some better way to do what I am trying to do? Note that I'm using the DataProvider mechanism becuase my attempts at using data binding were not successful (to do what I need). -Peter

Peter Zaborski
Replied On October 15, 2003 08:30 PM UTC

I forgot to mention, I am setting AllowResizeToFit = false; in my code. -Peter

Administrator [Syncfusion]
Replied On October 16, 2003 08:08 AM UTC

The grid.Model.ColWidths.ResizeToFit is purely a functional call. It will size the columns according to the data in the columns at the time of the call. There is no way around that. So, after your dataprovider has been instantiated and has access to its data store, and after you have set this dataprovider to the DataProvider property of the grid, then if you call ResizeToFit, the grid should have access to the data it needs to do the sizing. Does this not work for you? Is there no way for you to call the ResizeToFit method after the data is available? Another thing you can do is to explicitly set the grid.Model.ColWidths[row] values to something yourself. This you can do without the grid having access to the actual data (though it would need access to the proper column count that might be part of your dataprovider).


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