Reputation: 61
The title says it.
Is it possible to always select the first item in a listbox?
I prefer not to use listbox1.selectedindex = 0
or something like that
because i have loads of listbox1.items.add
etc. and that would just make the code bigger.
so is there an option in a listbox or something..??
Thanks in advance.
Upvotes: 1
Views: 14567
Reputation: 14279
listbox1.SelectedIndex = 0
This is your best bet. You can also try .SelectedValue
but that won't help if you're trying to get "less code". You should bite the bullet on this one and just use SelectedIndex
. I dont think any alternative is going to be so much better to make it worth the effort.
Upvotes: 4