Listview question…
I am making a listview box of, for example, aa, aab, ba, bb, cc. I can populate the box with no issues (call it $listbox1)
I have a seperate textbox that accepts user input. On any text change, I want to hightlight the item in thej list box.
$mgmtgroupsall is my listbox.
$MgmtGroupLookup is a text box
————–
$MgmtGroupLookup_TextChanged={
$start = [int]0
$lookup = $([string]$mgmtgrouplookup.text)
write-debug "Starting record $($start) with a look up of ($lookup)"
for ($ct=$start$ct -lt $mgmtgroupsall.Items.Count; $ct++)
{
if ($([string]$mgmtgroupsall.Items[$ct]).startswith($lookup))
{
# This does not work…
$MgmtGroupsAll.SelectedItem = $ct # How do I set what line is displayed?
write-host "Line $($ct) is what should be highlighted"
break
}
}
What I am missing is how to programatically set the $MgmtGroupsAll listbox to have item #3 highlighted (as if I had chosen the scroll bar to show it).
In other words, I have a list of club members (about 4000). I want to be able to type "Smith" to then have the list box take me to the first line that starts with Smith.
I can get what line number that line is that should be displayed, but where (how) do I tell the listbox that it should be displaying that item # 200 (or 300, etc) in the list?
That is, when someone enters C in the text box, I want it to highlight the first entry that starts with C, etc.. Without having to re-work the array to display *ONLY* the C's..