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
1500
Manually create ValueList-like dropdown
posted

Hi,

I have to do something very similar to a ValueList-like dropdown in a cell based on DropDownEditorButton. Like this:

Right now, I host WinListView in the DropDownEditorButton, that works well, but one thing - from what I've read on the forum it looks like there is no way to determine the size (specifically the width) of the ListView needed to show the items correctly (there will be an elipsis, if an item is too long). In the case of the built in ValueList-like dropdown, the dropdown itself will scale horizontally automatically so that all items completely fit by width.

What is the control that shows Number  and Percent on the picture above - can I use it somehow to host within DropDownEditorButton? If not, which control would you host within the DropDownEditorButton taking into account that it should be sized correctly?

Many thanks!
Vitaly

  • 469350
    Verified Answer
    Offline posted

    Hi Vitaly,

    There's no easy way to do this. The ValueList uses a lot of pretty complex logic to measure the text based on the font and all of the different options it is currently using. The measurement has to take into account the font and all of the GDI Plus or GDI settings that are being used to draw the text in order to get an accurate measurement, in addition to any borders or other padding.

    I guess one thing you could do is use an UltraWinGrid with a single column instead of UltraListView. Then you could call PerformAutoSize on the column in the grid and use the width of the column as the width of your dropdown. You might have to add in some padding for borders and possibly add more for the ScrollBar (if needed), but at worst, you could end up with a scrollbar's worth of empty space if the scrollbar wasn't needed and at least nothing would get clipped.