Where is Clear? How can I clear all checks in a checkLISTBOX with out a loop?

Why did they get rid of clear. I have a checkbox with 50 items. I want the user to be able to reset the selected checked items to none. I need to be able to clear the selecteditems in a checkbox. Any ideas besides doing a loop

Thanks

Theresa



Answer this question

Where is Clear? How can I clear all checks in a checkLISTBOX with out a loop?

  • Maarten Zaagman

    I tried that it doesn't remove the physical checkmarks just clears the selected collection.


  • pravsaugat

    tattoo wrote:

    I think your only option is a loop



    Dim i as Integer
    For i = 0 To CheckedListBox1.Items.Count - 1
    CheckedListBox1.SetItemCheckState(i, False)
    Next


    Hope this helps.

    this loop will executed for total items count. so then why you cannot use checkedIndices property which only return the checked items.



  • Praisy Noel

    i think there is no direct method to do this.

    you can do like this

    Dim intX As Int32

    For Each intX In myCheckListBox.CheckedIndices

    myCheckListBox.SetItemChecked(intX, False)

    Next



  • BrandonD

    I know this is probably way too late, just happened across the post, but have you tried the following:

    myCheckListBox.Items.Clear();


  • CodeW

    I think your only option is a loop



    Dim i as Integer
    For i = 0 To CheckedListBox1.Items.Count - 1
    CheckedListBox1.SetItemCheckState(i, False)
    Next


    Hope this helps.


  • Yosmanor

    Then I believe you are stuck looping

  • ssalter

    Me.CheckedListBox1.ClearSelected()



  • Where is Clear? How can I clear all checks in a checkLISTBOX with out a loop?