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
245
Dynamically resize UltraGrid
posted

I have attached an UltraGrid to the right button of an UltraTextEditor, with the idea of creating a checked dropdown box.  This works fine except I would like grid to automatically adjust its width so that all the text is viewable. 

I seem to be able to do this by calling PerformingAutoResize on the visible columns, adding up their widths and making that sum the grid width.

The problem is when to do this.  If I do it in InitializeLayout, the first time the grid is displayed, the width is incorrect, but after that it is correct.  If I do it too soon, like right after I set the data binding, then the columns have not yet been created, so I can't do it.

Or if there is a better way, please let me know.  Thanks.

Parents
  • 469350
    Suggested Answer
    Offline posted

    If you are using v9.1 of the grid or later, there is built-in support for a multi-select checkbox list. So that would make things a lot easier.

    If you are not using that version and cannot upgrade, then I would suggest doing the auto-sizing of the grid columns immediately after setting the data source, rather than waiting for InitializeLayout. What's probably happening is that InitializeLayoutis not firing until the first time the grid paints, which doesn't happen until after the first time you drop it down, by which time it is too late, because the dropdown size was already determined by the size of the grid before it was sized to the columns.

Reply Children