We have a grid where the bands are set up with AllowColSizing = AllowColSizing.Syncroized but when I perform auto resize on the column it only resizes to fit information contained in the top most band that is associated with that column header. Is there a way to have it include all syncronized bands to that column header?
Hi Derek,
There's no PerformAutoSize method that will do this. But what you could do is use CalculateAutoSize on the column(s) instead. Basically, you would loop through each band and call CalculateAutoSize on each column in the same position and then use the biggest width you got back.
Thanks for the reply Mike. Is there an event I can handle when the user double clicks on the sizing portion of a column to achieve this?
Hm... well not really. There's no event for autosizing or double-clicking that particular area. But when the column is autosized, the AfterColPosChanged event will fire. So you could use that. It's a little inefficient, since your sizing will take place after the grid already sized the column, but I don't think it will be a big deal. You will need to prevent recursion, though, so you either need a flag or you have to use the EventManager to prevent the event from firing again.
Actually.... it just occurred to me that AfterColPosChanged might not work for what you want here, because you will not be able to distinguish between when the user AutoSizes the column or when they click and drag to size the column. But I'm, afraid I don't see any other way to do this - unless you disable the grid's built-in AutoSize functionality and re-implement it yourself.