tags:

views:

161

answers:

3

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

+2  A: 

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

listbox1.selectedindex = 0

The default behaviour is that selectedindex is set to 0. Which would be the first item in the list.
CAbbott
selectedindex = 1 will select the 2nd item in the list. 0-based indexing.
TheTXI
A: 

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()
Joop
+2  A: 

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

Bhaskar