Combobox dropdown not changing size

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
PaschalIT
Posts: 38
Last visit: Fri Jan 10, 2020 7:38 am

Combobox dropdown not changing size

Post by PaschalIT »

- Product, version, build: Powershell Studio v5.6.163

- Specify if you are running a 32 or 64 bit version: 64 bit

- Your operating system and if it is 32 or 64 bit: Win10 64 bit

Hello everyone,

I have a combobox of which I am dynamically updating the items within my code based on certain keypresses. The issue I'm encountering is:

The combobox starts out displaying what looks to be 30 items. The list of items then changes as keys are pressed, and eventually the list becomes shorter than 30 items. The combobox then does not shrink its display to match the number of items, but rather remains expanded at its size which would show 30 items, and I can verify that the items are in fact removed. The $combobox.Items.Count property shows the expected number of items.

Image

I feel like the control should auto-size itself as the items are added or removed. The only thing that I can think of that may be causing an issue is that I am setting the $combobox.DroppedDown property to true.

Any thoughts/input on this? Is there a better way to do it?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox dropdown not changing size

Post by jvierra »

Using any normal methods I cannot reproduce you issue.

Note that the "DroppedDown" property I mostly useful for detecting that the list is displayed. While the list is displayed it will not change. Un-display the list a redisplay it and it will be correct.
PaschalIT
Posts: 38
Last visit: Fri Jan 10, 2020 7:38 am

Re: Combobox dropdown not changing size

Post by PaschalIT »

That's the issue, though. I need it to be displayed. The reason all of these events are happening is because I'm handling a custom smart search script that allows for (essentially) ANR, and I have to tell the dropdown to expand in order for it to display. If I retract the dropdown, whatever the user is typing in the combobox gets deleted since it wasn't confirmed.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Combobox dropdown not changing size

Post by jvierra »

You are trying to use the control in a way that it is not designed to be used. You will have to create a custom display that is like the dropdown that you can control as you like from your code.
PaschalIT
Posts: 38
Last visit: Fri Jan 10, 2020 7:38 am

Re: Combobox dropdown not changing size

Post by PaschalIT »

Well, I ended up hacking up a workaround. It's not the cleanest thing and it introduces a minor amount of flicker, but at least for the meantime it will work. I'll experiment more next week.
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked