Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
690
Serious problems with Column Widths
posted

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.:

  1. Setting child band column widths only
  2. Setting the widths forwards for the parent band only
  3. Setting the widths backwards, starting with the last column in the child band
  4. Doing each exclusively so I don't set Band[0].Column[0] AND Band[1].Column[0]

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

Parents
  • 469350
    Offline posted

    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.

Reply Children
No Data