CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Posts
    23

    multiselect property of the listbox should be max 7 items

    hi
    can some1 pls help. i need to make a listbox multiselect but the user can select only 7 items from the list. From the multiselect property of the list box i am selecting simple option. this property allows the user to select more then 7 items from the list box but i want the user can select only 7 items.

    can some1 pls tell how to go about

    thanks in advance.

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: multiselect property of the listbox should be max 7 items

    Put this code in the Click/MouseDown Event of the Listbox. This will allow only 7 items to be selected
    Code:
    	'Check if the Selected Item count is greater than 7
    	If List1.SelCount > 7 Then
    		'Set the last Selected Item as False
    		List1.Selected(List1.ListIndex) = False
    		'Display a Message
    		MsgBox "You Cannot Select more than 7 Items", vbInformation
    	End If

  3. #3
    Join Date
    May 2005
    Posts
    23

    Re: multiselect property of the listbox should be max 7 items

    Thanks u r suggestion worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured