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.
Unfortunately, activation email could not send to your email. Please try again.

Virtual grid and auto resizing cols and rows . .

Thread ID:

Created:

Updated:

Platform:

Replies:

33561 Aug 22,2005 10:24 PM Aug 23,2005 09:13 AM Windows Forms 3
loading
Tags: GridControl
Adam K.
Asked On August 22, 2005 10:24 PM

i am using QueryRowHeight and QueryColWidth i want to determine the size for some cols and rows and all the other be autofit based on the value. i am using a virtual grid . . thks, ak

Administrator [Syncfusion]
Replied On August 23, 2005 03:16 AM

You might try this. Have a Hashtable with the keys being some unique ID (could be a col index if you do not allow col moving, or could be a column title or something else unique) for the columns that you want to have a particular size and the values in teh Hashtable being the size. Also have a variable that tracks the total of the cached sizes. Then in QueryColWidth, check to see if e.Index is in teh Hashtable, and if so, return the cached size. If not, then return the (grid.ClientWidth - SumOfCachedSizes) / NumberOfNonCachedColumns. Make sure anytime you change a value in teh Hashtable, you call grid.ResetVolatileData (or grid.Refresh) to be sure the grid forces QueryColWidth to be hit so your new sizes are used. Take a look at this sample. http://www.syncfusion.com/Support/user/uploads/GridColWidthSample_28e65d76.zip When you run it, click the ''specified'' radio button and then click the Apply button. Then size the form so its width changes. You will see certain columns (as specified by the values in teh list) always occupy the specified percentage of the client area using a technique similar to what I suggested above.

Adam K.
Replied On August 23, 2005 07:39 AM

ok, we are getting somewhere but i am not sure if i explained properly i do have a hashtable with the cols that i want to keep track of specific widths (keyed off of colindex) and i do a looking during the QueryColwidth . .that works fine . . the issue is with the other cells. the question is that i don''t want the rest of the cols to simply fill up the client area. I want the rest of the cols to be autosized based on the width of the largest text width in that column does that makes sense. thanks, ak >You might try this. Have a Hashtable with the keys being some unique ID (could be a col index if you do not allow col moving, or could be a column title or something else unique) for the columns that you want to have a particular size and the values in teh Hashtable being the size. Also have a variable that tracks the total of the cached sizes. Then in QueryColWidth, check to see if e.Index is in teh Hashtable, and if so, return the cached size. If not, then return the (grid.ClientWidth - SumOfCachedSizes) / NumberOfNonCachedColumns. > >Make sure anytime you change a value in teh Hashtable, you call grid.ResetVolatileData (or grid.Refresh) to be sure the grid forces QueryColWidth to be hit so your new sizes are used. > >Take a look at this sample. > >http://www.syncfusion.com/Support/user/uploads/GridColWidthSample_28e65d76.zip > >When you run it, click the ''specified'' radio button and then click the Apply button. Then size the form so its width changes. You will see certain columns (as specified by the values in teh list) always occupy the specified percentage of the client area using a technique similar to what I suggested above. >

Administrator [Syncfusion]
Replied On August 23, 2005 09:13 AM

I think the simplest way to do this is to also add the ''other columns'' to your hashtable. When you add them, call grid.Model.ColsWidths.ResizeToFit and set the value in the hashtable based on the returned optimal colwidth. Now as you are making the ResizeToFit call and getting the width by calling grid.Model.ColWidth[col], unhook your QueryColWidth event (or set a flag or something) so that you do not try to provide the colwidth through your handler in this situation.

CONFIRMATION

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.

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.

;