Skip to content

Checked ListBox ClearSelected() not working #541

Closed

Description

@itg-assistant

Michael Hensen asked 2017-01-16 18:55:08 UTC

I have 3.2.20 running but the CheckedListbox doesn't clear with ClearSelected() an not with chkListbox.Update()..
I now have this as a workaround:

for (int x = 0; x < mRoles.Count; x++)
{
lstRoles.SetItemChecked(x, false);
}

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-01-16 19:41:17 UTC

    ListBox.ClearSelected() is the same as ListBox.SelectedIndex = -1. It removes the selected item, not the checked ones. The CheckedListBox can have 1 selected item and multiple checked items.

    To uncheck all items you need to call SetItemChecked(), as you already did. Consider that an app may override the state of an item processing OnItemCheck and changing the state.

  2. added
    BugSomething is broken or behaving unexpectedly.
    on Jun 12, 2026
  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Michael Hensen answered 2017-01-16 19:56:48 UTC

    Ouch !! I misunderstood the ClearSelected, my wrong.. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions