does anyone have some ideas on how to highlight the first item in a listbox when the userform initializes?
thanks!!
does anyone have some ideas on how to highlight the first item in a listbox when the userform initializes?
thanks!!
[vba]
Private Sub Userform_Initialize()
Me.ListBox1.ListIndex = 0
End Sub
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
thank you very much.
does this initallly select 0 or just highlight it?
erik
How are you differentiating selecting from highlighting?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
good question. all i thought i was attempting to do is just highlight the first item in the listbox, not actually have it selected. i am not sure if it being selected is an issue (or not). i will have to play with it and see what, if anything, happens in a negative way to my rudimentary code.
i woulndt think so.
erik
If you only wanted it highlighted, not selected, you must understand those two things to be different. So I ask again, what do you mean by select and highlight?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
i do understand they are different. i was just looking to have it highlighted when the form initialized. as i am new, i am trying to learn all the different ways of accomplishing what i would like to do.
erik
If you're trying to learn, then build a userform and add a listbox and try some things. for example:
[VBA]
Private Sub CommandButton1_Click()
MsgBox ListBox1.Value
End Sub
Private Sub Userform_Initialize()
Me.ListBox1.ListIndex = 0
End Sub
[/VBA]
Results should answer some questions for you.
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Well, actualy I am saying that they are NOT different. Highlighted is just a visible stance on what is selected, so they are the same thing, or more accurately, they are differnt aspects of the same thing. That is why I asked as I were thinking of something slightly different.
If you do see them as the same thing as I do, there are no implications that I can see. Selecting an item in the listbox does highlight, and it will trigger the Listbox Click event, but other than that, nothing untoward.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber