Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
samueltilden@gmail.com - 24 Mar 2008 00:35 GMT
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.
Gilles Kohl [MVP] - 24 Mar 2008 10:11 GMT
>I have inherited a complex application with dozens of controls.
>
[quoted text clipped - 14 lines]
>
>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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.