Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to prevent ItemCheck event from firing

How to prevent ItemCheck event from firing

How to prevent ItemCheck event from firing

If I have a CheckedListBox with an ItemCheck event defined, how do I set it to fire only if a user actually selects a checkbox item not when I check it programmatically.

Right now, if I programmatically set all the checkboxes, I will enter the event code 10 times if I have 10 checkbox items.

I don't want it to fire at all here.

But when the user selects a checkbox, then I want it to fire.



RE: How to prevent ItemCheck event from firing

Assuming you have a method to perform some action when the checkbox is selected - perhaps called "checkbox1_CheckedChanged", the following should point you in the right direction.


private void CodeToDoWork()
    checkbox1.CheckedChanged -= checkbox1_CheckedChanged;
    //Your work goes here
    checkbox1.CheckedChanged += checkbox1_CheckedChanged;

Basically, the first line "removes" the event that you do not want fired when you change the state of the checkbox. You do the work you want to do. Finally, the last line "connects" the event back up to the CheckedChanged code.

I actually use the "+= some_event" a lot to assign the events to my controls on my Form_Load event because I do a lot of pre-processing and populating the screens before I want the fields to have any actionable events.

Robert "Wizard" Johnson III
U.S. Military Vets MC
Senior Database Developer

RE: How to prevent ItemCheck event from firing

That is exactly what I want to do.

But I have about 10 ChecklistBoxes that I want to pre-process but don't want the event to fire.

Is there a way to query the object (CheckListBox) to find out what the event handler for an event is so I can take it off and back on again. I want to run it from one method that just passes in the object and the object will stop the event, set some checkboxes in the object and then turn the event back on.



RE: How to prevent ItemCheck event from firing

It would.

I did answer it a few minutes ago.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close