Changing autocomplete behavior on combobox

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

Changing autocomplete behavior on combobox

Post by PaschalIT »

Product: Powershell Studio v5.6.163 64 bit
OS: W10 64 bit

Default functionality for a combobox autocomplete is to only register on prefixes, or -StartsWith. What I'm trying to find out is if there's a way to modify how it reads/matches against the combobox's items to where it functions more like -Contains, where the typed string can match anywhere within each item.

For instance, if I have the strings "Control", "Freedom", and "Dominate" in my combobox with autocomplete on and type "dom", the combobox will suggest:
"Dominate"

I would like it to suggest:
"Freedom"
"Dominate"

Is this possible?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Changing autocomplete behavior on combobox

Post by jvierra »

No. The ComboBox only matches based on the string match. Any other method would require you to write custom code to handle keystrokes and decide how to use them in a match.

You can also use an object collection that has a display string and a value. Make the display strings match-able and set the return value to the actual value you want.
PaschalIT
Posts: 38
Last visit: Fri Jan 10, 2020 7:38 am

Re: Changing autocomplete behavior on combobox

Post by PaschalIT »

Thanks for the reply, jvierra.

I'm already midway through writing my own _KeyPress event, but I just wanted to ask you guys before I got too deeply involved in it. Good to know that my current path is probably the best one.

Cheers
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Changing autocomplete behavior on combobox

Post by jvierra »

It shouldn't be too hard to create a custom lookup. Good luck.
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