-
February 6th, 2003, 02:18 AM
#1
Multiselect in Listbox
I am using listbox control with Multiselect option set to Simple. Is it possible to restrict the number of items selected by the user? For example, I want user to select 5 items & if he try to select more, he should get a message that maximum items are selected and it should not be possible for him to select any more items. Is it possible to set the multiselect property at runtime?
-
February 6th, 2003, 02:41 AM
#2
Try this with a form containing listbox named list1:
Private Sub List1_Click()
If Me.List1.SelCount > 5 Then
List1.Selected(List1.ListIndex) = False
MsgBox "No way man! you have selected 5 item"
End If
End Sub
-
February 6th, 2003, 04:59 AM
#3
Thanks. The code serve the purpose.
But, is there any way to set Multiselect at runtime?
-
February 6th, 2003, 02:36 PM
#4
No- At run time time that property is read only. But if you set it to Extended at design time you can modify its behaviour with the code you have and the _MouseDown Event to SIMULATE any other mode.
Your code can only be as good as your algorithm.
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
|