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.
Locked
PaschalIT
Posts: 32
Joined: Tue Apr 02, 2019 4:37 pm

Combobox dropdown not changing size

Post by PaschalIT » Fri May 17, 2019 9:19 am

- 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?

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Combobox dropdown not changing size

Post by jvierra » Fri May 17, 2019 11:34 am

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: 32
Joined: Tue Apr 02, 2019 4:37 pm

Re: Combobox dropdown not changing size

Post by PaschalIT » Fri May 17, 2019 12:45 pm

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.

User avatar
jvierra
Posts: 13682
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Combobox dropdown not changing size

Post by jvierra » Fri May 17, 2019 1:06 pm

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: 32
Joined: Tue Apr 02, 2019 4:37 pm

Re: Combobox dropdown not changing size

Post by PaschalIT » Fri May 17, 2019 2:01 pm

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.

Locked