Select row in list box programatically

B

Brad

Thanks for taking the time to read my question.

I would like to select an item in my listbox with code.

so far I have:
Me.CategoryList.Column(1, x) but you can't add anything after that.

It also is incorrect. If I add Msgbox before it, it returns that value.

I'd like to select that value.

How do I do that?

I don't think ListIndex, ItemData are the right ones either.

Thanks again,

Brad
 
D

Dan Artuso

Hi,
It's hard to tell how you want to use this but, here's one way:

Dim i As Integer
For i = 0 To Me.CategoryList.ListCount - 1
If Me.CategoryList.Column(0, i) = Me.CategoryList.Column(1, x) Then
Me.List0.Selected(i) = True
End If
Next i
 
D

Dan Artuso

Hi,
Sorry, wrong list box in previous code :)
Dim i As Integer
For i = 0 To Me.CategoryList.ListCount - 1
If Me.CategoryList.Column(0, i) = Me.CategoryList.Column(1, x) Then
Me.CategoryList.Selected(i) = True
End If
Next i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top