I'm a little stumped, hoping for some guidance.
In my UltraWinGrid, I'm making use of the PerformAutoResize method after my data load because I like the functionality of having all columns resize themselves to fit the largest cell (and header) value. However, this often results in extra unused space to the right of the last column.
Browsing through the properties, I stumbled on to the AutoFitStyle property, specifically the "ExtendLastColumn" option which is ideally like to have happen.
However, I can't seem to make the two approaches work. What I want is a combination of "resize every column with regards to it's cell and header values...except the last column which should disregard it's autosize value and extend to the end of the grid".
Is there a way to do that? It seems like I can only do one or the other.
Thanks!
Chris Rowland
Hi Mike, I am facing an issue with ultraGridColumn.PerformAutoResize(PerformAutoSizeType.VisibleRows, true). Auto Resize of columns are not working properly, but when we switch from tabs to tabs then Auto Resize is working fine with the same code.. Any suggestion on this?
Hi Chris,
Your initial post seemed to imply that your grid is showing flat data (no child bands). Is that correct?
Horizontal view means that the child rows are displayed to the right of the parent rows. So ExtendLastColumn doesn't make a lot of sense in that view and I'm not surprised it does not work.
In the case of flat grid, you wouldn't see much difference in the display between horizontal and vertical view. So, if you don't want OutlookGroupBy, then it seems like you should just be using vertical (which is the default), and then the autofit should work.
I unmarked this as an answer because, well, I'd like to know whether it's interaction with the ViewStyleBand is intended. If so, then I'll take it as an answer.
Hi Mike, thanks for the prompt reply again (as usual!)
So I took your code and threw it into a new sample project and, like you said, it works fine. So I set off to try to find what was different between the sample and my production code. Eventually I was able to track it down.
In my production code, I had set the ViewStyleBand to ViewStyleBand.Horizontal
In my sample code, it appears the default ViewStyleBand is ViewStyleBand.OutlookGroupBy.
When the view style is set to OutlookGroupBy, the extend last column works great. But when set to Horizontal, it ignores the extend last column. When I set the viewstyleband back to OutlookGroupBy, it worked like a champ.
You're the expert so you can tell me whether that's a bug or an interaction of two properties that I *should* have known but didn't.
What's not working? I tried this out and it seems like it works okay to me. It's probably a good idea to do the resizing before you set the AutoFitStyle. Or, if you do it the other way, don't try to autosize the last column.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; foreach (UltraGridColumn column in band.Columns) { column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, AutoResizeColumnWidthOptions.All); } layout.AutoFitStyle = AutoFitStyle.ExtendLastColumn; }