Hi there.
Ok I'm not new to the Infragistics way of things, been using this UltraWinGrid for the best part of 5 years now. However I'm having an awful time saving and loading column settings. My code is too complex to easily put here, so I'll explain.
I've got a grid which is loaded after a treeview click, during this process it fires various callbacks etc to save the current "state" of the grid and other UI elements the user has changed. When the state is saved, the datasource is changed, InitializeLayout is fired, then my code swoops in afterwards to merge in the user preferences, like which rows are expanded and more importantly column widths.
Now this should work, however doing this repeatedly results in my columns expanding in width each time the code is run. It's almost like it's doing width = myWidth + 10 just to annoy me.
I've tried for hours now, many workarounds. There are some cases that work and don't work, e.g.:
UPDATE
I just tried setting AllowColSizing = AllowColSizing.Free and the effect is no longer visible. However my code is only setting ONE column index from each band so it's not fully tested.
Does this make any sense to anyone? How can I set sizes after InitializeLayout effectively?
UPDATE 2
Right it's definitely somehow linked with Synchronized columns. My code works perfectly in Free mode.
Thanks, Tom
Hi Mike, thanks for the response. You seem to understand my rambling question perfectly!
I did try to overcome the setting of widths multiple times by either setting only band 0 or band 1 if it didn't exist in band 0. I also tried this the other way around, setting band 1 only which sortof worked for a bit, until I had more columns in band 0 than band 1. I also tried doing the column setting in reverse, setting the last column in the last band, up to the first column in the first band, providing I hadn't already set the column in the last band already... Phew.
Ah I just checked. My InitializeLayout disables AutoFitStyle. It's very complicated, so I'm ok with leaving it as Free at the moment, but thank you very much for shedding some light onto how difficult this actually is!
Tom
Hi Tom,
My guess is that you are also using AutoFitStyle. If the columns are being auto-fit to the width of the grid then setting the width on the column doesn't always come out exactly to the pixel you set it to, because setting the width on one column affects the width of the previous columns whose widths you already set.
This would be especially noticable if you were setting the width on each column multiple times - which is essentially what happens if the column widths are synchronized and you set the width of each column each band. In other words, if the columns are synchronized, setting the width of column 0 in band 0 is the same as setting the width of column 0 in band 1. So there's no reason to do both.
If I am right, then another potential solution for you is to leave the columns synchronized, but only set the widths of the columns in band 0 and ignore all of the other bands. In fact, it's a bit more complicated, because it's possible that a child band has a greater number of columns than band 0 - in which case some of the column width would never get set. So you would actually have to only set the width on the columns of whatever band has the highest number of columns.