|
-
Oct 18th, 2000, 04:24 PM
#1
I have a checked listbox. I would like to initialise all options to be checked initially. I tried to put the following in the form Load:
For i = 0 To lstChoices.ListIndex - 1
lstChoices.Selected(i) = True
Next i
But the above does not display checks on my screen. How do I display a checkbox with all list entries checked when initialise the form?
-
Oct 18th, 2000, 05:03 PM
#2
Try this:
Code:
Private Sub Form_Load()
With List1
For i = .ListCount - 1 To 0 Step -1
.Selected(i) = True
Next
End With
End Sub
-
Oct 18th, 2000, 05:43 PM
#3
Thanks, Matthew!
It worked perfectly!
I would like to understand why mine did not work and yours did? I can see you went backwards with i, does this matter?
Many thanks,
Sandra
-
Oct 18th, 2000, 05:57 PM
#4
For i = 0 To lstChoices.ListIndex - 1
lstChoices.Selected(i) = True
Next i
You have ListIndex. This is the reason it does not work because it's not actually counting anything on the List.
It does not matter whether you go backwards or not.
This will work as well:
Code:
For i = 0 To List1.ListCount - 1
List1.Selected(i) = True
Next i
-
Oct 18th, 2000, 06:02 PM
#5
Yes, got it. Listindex was a typo, I meant ListCount. "Looking at it and not seeing it" was my sindrome.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|