Any method like System.Windows.Forms.Application.CancelEvents()?

  • Thread starter Thread starter samueltilden
  • Start date Start date
S

samueltilden

I have inherited a complex application with dozens of controls.

The new functionality I am to surgically insert is to prevent the user
from proceeding further if any of the data is incorrect in my control
on the current page.

I can capture the .Leave event from my control, but I do not want
Windows to honor the destination control that the user clicked. Is
there such a way to tell Windows to CancelEvents and do not activate
the control that the user clicked?

If there were, this method would be something like:

System.Windows.Forms.Application.CancelEvents(), instead of:

System.Windows.Forms.Application.DoEvents()

Thanks.
 
I have inherited a complex application with dozens of controls.

The new functionality I am to surgically insert is to prevent the user
from proceeding further if any of the data is incorrect in my control
on the current page.

I can capture the .Leave event from my control, but I do not want
Windows to honor the destination control that the user clicked. Is
there such a way to tell Windows to CancelEvents and do not activate
the control that the user clicked?

If there were, this method would be something like:

System.Windows.Forms.Application.CancelEvents(), instead of:

System.Windows.Forms.Application.DoEvents()

Thanks.

Not sure if you are _providing_ controls, or using existing ones.

If the latter, have you considered handling the "Validating" event of the
control?

http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.validating.aspx

(Specifically have a look at the example in there - it prevents focus from
moving away from a textbox if the entered text does not look like an email.)

If the former, overriding OnValidating and adding your own custom validation
(after calling the base class's OnValidating method so that registered
delegates receive the event) could be the way to go.

Regards,
Gilles.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top