Page 1 of 1
combobox filtering/autocomplete input
Posted: Tue Nov 26, 2019 2:44 pm
by lontru
Hi
Is there a way to filter the result in the combobox to match what you type like this
tried a textchanged event on the combobox but when you type in it get invertet the input?
$TextChanged = $cars | Where-Object { $_.TemplateName -like "*$($combobox1.Text)*" }
Update-ComboBox $combobox1 $TextChanged -DisplayMember "TemplateName"
so how do i filter the result in the combobox - so when i type ex "ford" it should only show ford in the dropdown?
Re: combobox filtering/autocomplete input
Posted: Tue Nov 26, 2019 2:54 pm
by jvierra
Set the "AutoCompleteMode" filter on the properties tab. It is under "Misc" at the bottom:
https://docs.microsoft.com/en-us/dotnet ... mework-4.8
Re: combobox filtering/autocomplete input
Posted: Wed Nov 27, 2019 12:23 am
by lontru
doesnt do anything?
$form1_Load={
Update-ComboBox $combobox1 $cars
$combobox1.AutoCompleteMode = 'SuggestAppend'
}
should it not suggest when i typing : Fo
The function im looking for is something like this
When i type "on" in the box it should limited the list to
Gordon Murray
Honda
Aston Martin
Proton
$cars | Where-Object {$_ -like "*on*"}
Can it be done? with textchanged event
Re: combobox filtering/autocomplete input
Posted: Wed Nov 27, 2019 12:55 am
by jvierra
It works for me but you haven't set the source for the autocomplete. Read the docs on using autocomplete. It has a complete example.
AutoCompleteSource = 'ListItems'
Re: combobox filtering/autocomplete input
Posted: Wed Nov 27, 2019 1:18 am
by lontru
it works now - but this method req that you know the begining of the word you looking for.
$form1_Load={
Update-ComboBox $combobox1 $cars
$combobox1.AutoCompleteMode = 'SuggestAppend'
$combobox1.AutoCompleteSource = 'ListItems'
}
if i was looking for these item in the list
"Bentley TEST"
"Mini TEST"
"Volvo TEST"
by typing "tes" i would not get the result wanted but it will suggest "Tesla Motors"
So somehow i need a filteret result in the dropdown when typing in the box.
Re: combobox filtering/autocomplete input
Posted: Wed Nov 27, 2019 10:04 am
by jvierra
There is really no way to do that with a ComboBox. You would have to create a custom control set with a textbox and a ListBox that are data bound and use the DefaultDataView "RowFilter" to filter the list.