limit the user by selecting 3 three items from a check list box

rocks_lp

Member
Joined
Dec 16, 2008
Messages
15
Programming Experience
Beginner
i have a check list box. i want the user to limit, selecting maximum of three items from the checklistbox. if user select more than that i want a msgbox to prompt.

how can i code for this.
plzz help
plz plzzzzzzzzzzzzzzz
 
Thread moved to Windows Forms forum, this is more specific for your topic than VB.Net General forum.

VB.NET:
Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
    If Me.CheckedListBox1.CheckedItems.Count = 3 AndAlso e.NewValue = CheckState.Checked Then
        e.NewValue = CheckState.Unchecked
        MsgBox("You can only check 3 items.")
    End If
End Sub
 
Back
Top