Windows Develop Bookmark and Share   
 index > Windows Forms General > Checkbox Validate Event
 

Checkbox Validate Event

I'm working on a form with multiple checkboxes. I have hooked the validated event to all the boxes. My problem occurs with the last checkbox that is clicked. After the user clicks the box and later the save button the validated event does not fire for this box. I tried putting the focus on another control as the first step in the save call, but still no luck.

I do not want to use the CheckedChanged because when I load the form it gets called when I'm setting the values from the object, and it loops the update to the object again making the object dirty.

Your help is much appreciated.

Thank you.
JFercan  Wednesday, March 04, 2009 7:21 PM
I can think of two things:

1. If it is an ordinary button, the CausesValidation property of the Button might be false. This is not the default, but verify.

2. if it is a toolbar button, these do not validate and there is no CausesValidation property. You can force validation in the ToolClick handler by calling the Form's Validate method.

privatevoidtoolStripButton1_Click(objectsender,EventArgse)
{
if(this.Validate())
{
//Validationokay.Proceed.
}
}


  • Marked As Answer byJFercan Friday, March 06, 2009 9:41 PM
  •  
BinaryCoder  Thursday, March 05, 2009 12:01 AM
I can think of two things:

1. If it is an ordinary button, the CausesValidation property of the Button might be false. This is not the default, but verify.

2. if it is a toolbar button, these do not validate and there is no CausesValidation property. You can force validation in the ToolClick handler by calling the Form's Validate method.

privatevoidtoolStripButton1_Click(objectsender,EventArgse)
{
if(this.Validate())
{
//Validationokay.Proceed.
}
}


  • Marked As Answer byJFercan Friday, March 06, 2009 9:41 PM
  •  
BinaryCoder  Thursday, March 05, 2009 12:01 AM
Thanks for your answer. Your second solutions is what I'm doing now.
JFercan  Friday, March 06, 2009 9:41 PM

You can use google to search for other answers

Custom Search

More Threads

• Moving Forms
• Changing the system setting on the computer changes colors of some control on the UI.
• I am unable to provide persistence to drawing a line using Mouse at runtime.
• Windows Service Communicating with a WebService
• Multiline Textboxes and new lines
• Problem in Crystal Reports V9.0
• How Could I protect my application ?
• browser & winform
• setting label value in formview verses outside the formview control
• TableLayoutPanel- Distorted view while scrolling.