I created a menu option to set the AutoFitStyle on my grid.
From default (AutoFitStyle.None) to AutoFitStyle.ResizeAllColumns and to AutoFitStyle.ExtendLastColumn works fine.
From AutoFitStyle.ExtendLastColumn back to AutoFitStyle.None works fine also.
But AutoFitStyle.ResizeAllColumns back to AutoFitStyle.None or AutoFitStyle.ExtendLastColumn doesn't work. It remains on AutoFitStyle.ResizeAllColumns.
I tried: this.ultraGrid.Selected.Rows.Clear();and this.ultraGrid.Refresh();before changing the AutoFitStyle but nothing seems to work.
What am I doing wrong ?
Works like a charm !
Thx. I'll give it a try.
this.ultraGrid1.DisplayLayout.Save...
You can save the layout to a file or to a memory stream, as XML or as binary. You could also use the DisplayLayout.Clone method to simply copy the layout into another UltraGridLayout variable and store it in the grid's Layouts collection.
Mike Saltzman"]...or save the grid layout before setting the style.
What's the best way to save the grid layout?
Okay, I think this is just a difference in the way the styles are implemented. For the ExtendLastColumn style, the column's width property is not changed, the grid just stretches the column's UIElements so it looks wider. For the ResizeAllColumns style, the column widths are explicitly set, so the original widths are lost.
So maybe you could store the widths of the columns or save the grid layout before setting the style. You could keep 3 different layouts in memory and when the user switches back to that style, you load the layout or set the column widths to what they were in the previous style.