locked
vb.net checked list box RRS feed

  • Question

  • Hi all 

             I have a checked list box having some items .When I click any item it first select the item and then when I again click it then check box is checked/unchecked How to change this behaviour means I want to perform selection and check/uncheck action in a single click


    bahushekh
    Monday, February 14, 2011 8:56 AM

Answers

  • Set the CheckOnClick property to True.

    • Proposed as answer by spotty Monday, February 14, 2011 3:30 PM
    • Marked as answer by bahushekh Tuesday, February 15, 2011 6:16 AM
    Monday, February 14, 2011 9:45 AM

All replies

  • Try something like this:

      Private Sub CheckedListBox1_click _
        (ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles CheckedListBox1.Click

            If CheckedListBox1.GetItemChecked _
            (CheckedListBox1.SelectedIndex) = False Then
                CheckedListBox1.SetItemChecked _
                (CheckedListBox1.SelectedIndex, True)

            ElseIf CheckedListBox1.GetItemChecked _
            (CheckedListBox1.SelectedIndex) = True Then
                CheckedListBox1.SetItemChecked _
                (CheckedListBox1.SelectedIndex, False)

            End If

    Note that the above works when you click on seperate checkboxes and each of them will be checked_and_selected or unchecked_and_unselected on each "single" click at the same time . HTH.


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    Monday, February 14, 2011 9:25 AM
  • Set the CheckOnClick property to True.

    • Proposed as answer by spotty Monday, February 14, 2011 3:30 PM
    • Marked as answer by bahushekh Tuesday, February 15, 2011 6:16 AM
    Monday, February 14, 2011 9:45 AM
  • hi onur I applied your solution .it works fine if I click on a non selected item but If I click on a selected item Then I need to double click for check Change

     

    Thanks


    bahushekh
    Monday, February 14, 2011 12:34 PM
  • hi onur I applied your solution .it works fine if I click on a non selected item but If I click on a selected item Then I need to double click for check Change

     

    Thanks


    bahushekh


    Hi, yes i noticed it.  For a shorter solution, you can simply set CheckOnClick property to true at design-time, as JohnWein suggested.

    HTH.


    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları'ndayım.

    Microsoft Haber Grupları Profilim (VB.NET)

    Monday, February 14, 2011 3:13 PM