Preventing an item from highlighting in a checkedlistbox.

I am looking for a way to prevent the item listed in a checkedlistbox from highlighting when I click in the checkbox. It's a rather annoying visual when this happens. I have it set to clearselection when the checkbox is clicked but i really would like it not to occur at all.

         TIA,
                 Rick



Answer this question

Preventing an item from highlighting in a checkedlistbox.

  • Laura Cavanagh

    If you are trying to prevent an item from being checked, the procedure is quite simple:

    private void checkedListBox1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
    {
        e.NewValue = e.CurrentValue;
    }

    This code will of course prevent all the items from being checked, but I believe you got the idea.

     

    Itay Sagui  | Tzunami Technologies
    Tel: +972-9-9507479  |  Mobile: +972-54-5343800  |  Email: itay@tzunami.com< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

     


  • Drca

    Maybe try to save the selected index value on each selection, and when you find out that the source is a check click, restore the old value back.

    If this doesn't help,I'll post on sunday a custom CheckedListBox that you can modify for this behavior.



  • Preventing an item from highlighting in a checkedlistbox.