1

Is there any way to give a ComboBox formatted as a DropDownList the same functionality as with HTML select?

What I mean is that if you type the letters "Es", the dropdownlist automatically selects the first value with "ES*" as it would be the case with HTML select? Right now, by entering the second letter, the list jumps to "Ssp1" instead of "Esp1"

Any ideas?

HTML reference: https://jsfiddle.net/j7h2326c/4/

PowerShell Example:

    Add-Type -AssemblyName System.Windows.Forms
    $form = New-Object System.Windows.Forms.Form
    $combobox1 = New-Object System.Windows.Forms.ComboBox
    $form.Controls.Add($combobox1)


    $combobox1.Location = '30,30'
    $combobox1.DropDownStyle = 'DropDownList'
    $combobox1.Items.AddRange(@('Term add 1', 'Term add 2', 'Term more 1', 'Esp1', 'Esp2', 'Ssp1'))

    $form.ShowDialog()

2 Answers 2

3

Set the ComboBox Auto-complete Mode to Append

$combobox1.AutoCompleteMode = 'Append'
Sign up to request clarification or add additional context in comments.

1 Comment

thanks. This lead me towards my goal. There was only one more thing missing (setting the AutoCompleteSource) I answered my own question if you dont mind.
1

Avshalom pointed me to the right direction. There where only two things missing:

$combobox1.AutoCompleteSource = 'ListItems'
$combobox1.AutoCompleteMode = 'Append'

so the complete code would be:

    Add-Type -AssemblyName System.Windows.Forms
    $form = New-Object System.Windows.Forms.Form
    $combobox1 = New-Object System.Windows.Forms.ComboBox
    $form.Controls.Add($combobox1)


    $combobox1.Location = '30,30'
    $combobox1.DropDownStyle = 'DropDownList'
    $combobox1.AutoCompleteSource = 'ListItems'
    $combobox1.AutoCompleteMode = 'Append'
    $combobox1.Items.AddRange(@('Term add 1', 'Term add 2', 'Term more 1', 'Esp1', 'Esp2', 'Ssp1'))

    $form.ShowDialog()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.