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.

overriding controller event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alexia.bee@gmail.com - 18 Mar 2008 08:16 GMT
Hi All,

I've created a crontroller which has 3 text boxes. I set for all text
boxes in this cotroller a key_press event.
In my other app which uses this controller, I want to override the
key_press event of the first text boxes in the controller.

Is there a way to override an event of controller or the first text
box of the 3?

Thanks,
Alexia.
Peter Duniho - 18 Mar 2008 09:02 GMT
> Hi All,
>
[quoted text clipped - 5 lines]
> Is there a way to override an event of controller or the first text
> box of the 3?

Not really, not without the cooperation of your controller.  You can  
subscribe to the event if the TextBox control is public, and depending on  
what you are really trying to do, you _might_ be able to cancel or  
otherwise undo something that the controller does in response to the event.

For example, assuming your client class subscribes to the event after the  
controller, and assuming all you want to do is handle something in the  
event that the controller doesn't, or prevent the controller from  
signaling that it has handled the event, then you could just set the  
Handled property in the event and since your code would execute after the  
controller's, you win.

But you can't stop the controller from handling the event altogether.  And  
even in the example I describe, it's a somewhat fragile situation, as  
you're completely dependent on the assumption that the controller  
subscribes to the event before you do.

If you want to override the controller's own event handling, you should  
change the controller so that it's designed to allow this.  That would not  
be hard at all and the resulting code would be a lot more robust and  
maintainable.

Pete

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.