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
890
Programmatic column resizing when AutoFitStyle = ResizeAllColumns
posted
Hi all,

I've got an issue with column resizing.

Basically, I have 2 grids on a form. Both have ".DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns". When the user resizes a column in one of the grids, I want the "matching" column in the other grid to be resized the same.

Seems pretty simple but I can't get this to work! The "other" column's size is always slightly different. The more you resize the column, the greater the sizing error. If I set AutoFitStyle = None, the issue goes away (but of course, I want AutoFitStyle = ResizeAllColumns).

A sample project is available here. If anyone could suggest a solution I'd be grateful.

Regards,

Scott Pearce
  • 469350
    Verified Answer
    Offline posted

    Hi Scott,

    I can't find any good way to do this. The problem is that when you use ResizeAllColumns, the size of one column affects the size of all of the other columns. There is special logic in the grid so that when you drag a column size in the UI that it sets that column to the size you want and then resizes only the other columns. But there's apparently no way to do this in code - or at least no way I can find. 

    It probably would not be a big deal to expose such a method, so I recommend that you Submit an incident to Infragistics Developer Support. It's a good idea to include a link to this post so they can see we have already dicsussed the issue and that I asked you to submit it. 

    In the mean time, if you switch UseRowLayout on, then I think you can get the behavior you want by using the column.RowLayoutInfo.ActualLabelSize property. But this may not be a viable workaround, since using RowLayouts will exclude some other grid features such as Groups and FixedHeaders.