Check Box Change Event

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

All,

I have a form with a check box on it for which I have
implemented a CheckedChange event. The form is the front
end of a complex data entry system. When I load the form I
check for previously entered data and load that into the
form. If a certain value exists then I set the CheckBox
Checked property to true. The problem that I have is that,
when the form Loads the CheckedChange event fires and that
code executes. I don't want that to happen. How do I get
around that? What should I be doing in order to control
that event?

Thanks for the help!

Dan
 
The easiest way probably is to set a flag for yourself so
that your CheckChanged event handler knows whether it
should process the event.

private bool loading;

private void LoadForm(){
loading = true;
//Code to load the form
loading = false;
}

Then in your event handler...

private void checkBox1_CheckChanged(object sender,
EventArgs e){
if(loading){ return; }
//Process event
}


Charlie
 
Back
Top