I always wanna mark the first item in my listbox when I start the form. How do I do that?
Printable View
I always wanna mark the first item in my listbox when I start the form. How do I do that?
VB Code:
Private Sub Form_Load() List1.ListIndex = 0 End Sub
VB Code:
Private Sub Form_Load() If List1.ListCount > 0 Then List1.ListIndex = 0 End If End Sub
List1.Selected(0) = True
If I use List1.Selected(0) = True, the first item selected. But I still must click on the listbox to get the value to my code? Why?
...because I don't think it fires off any events...
Woka
Call the click event of the list after you set the selected item
VB Code:
List1_Click
...or use Axion's or Swatty's code :D
Woka
which control are you using ??
VB Code:
Private Sub Form_Load() List1.AddItem "hoera" List1.Selected(0) = True End Sub Private Sub List1_Click() MsgBox "clicked" End Sub
Worked for me without calling the click event.