Alex Gordon
Alex Gordon

Reputation: 60711

setting default selection for listbox?

how do i make it say that on form load, the first item in the listbox is selected?

Upvotes: 4

Views: 24139

Answers (3)

Sumit
Sumit

Reputation:

Hi you can use the SelectedIndex Property of listbox for eg.

listbox1.selectedindex = 0

Upvotes: 5

Bhaskar
Bhaskar

Reputation: 10681

Using of the selected indix is the best way - listbox1.selectedindex = 0 (since it is a 0 based collection)

Upvotes: 4

Joop
Joop

Reputation: 2839

As far as I know the first item is always selected if no other item is assigned to be. If you want to reset it back to the first item to be selected, a better approach in my opinion is:

listbox1.ClearSelection()

Upvotes: 0

Related Questions