overriding controller event

  • Thread starter Thread starter alexia.bee
  • Start date Start date
A

alexia.bee

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.
 
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?

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
 
Back
Top