Enabling checkboxes in a listbox control

  • Thread starter Thread starter Tokash
  • Start date Start date
T

Tokash

I know to enable a checkbox for a listbox with a plain
liststyle would be something like:

Userform1.Listbox1.Text = "Listitem1"

How does one do this for an option liststyle? I'm looking
to be able to multi-select several items in a listbox with
the listbox liststyle set as an "option" list style with
multiselect property set as "multi".

Here's the code I have:

Dim A As Boolean
With Userform1.Listbox1
For I = 1 To 10
.AddItem Z(I)
If A Then
' Code here to checkbox if A is true.
End If
Next I
End With

Putting in the line "Userform1.Listbox1.Text = Z(I)" only
work for plain liststyles and only if you want one box
checked. It fails when the listbox is setup for
an "option" liststyle with multiselect as "multi".

Is it doable this way or am I just smoking something
really good?
Any advice appreciated!
Thanks,
Tok
 
Oops, I really am smoking crack. I guess you can't enable
any checkbox in a plain liststyle as there are no boxes
displayed! I meant being able to check multiple boxes
with the liststyle property set as "option" and
multiselect set as "multi". Gah! If you kow the answer
to this, then you know what I mean. =D

Thanks,
Tok
 
Ahh, I found the answer from another source.

For those who may have the same problem and are wondering,
it's found in the ".Selected" property.

Dim A As Boolean, Z(9) As String, I As Integer
With Userform1.Listbox1
For I = 0 To 9
.AddItem Z(I)
.Selected(I) = A
End If
Next I
End With

Ok, it was probably easy for the guru's but I'm dumb.
Tok
 
Back
Top