invoking Events

T

Trollpower

Dear NG,

ive got a custom control 'A' with a custom control 'B' in it, both
written in C#. Ive implemented the onClick Event for both the
Controls. If i click on the 'B'-Control the appropriate event fires.
But after doing some work i also want the onclick-event of Control 'A'
to fire also.

I need the OnClickEvent in Control 'A' to fire from within Control
'B', because there is some code in the parent form of Control 'A'
which needs to be done. And by firing the OnClick-Event for the
Control 'A', the appropriate Method in the parent form gets invoked.
As far as i know i can fire an event in VB.NET with RaiseEvent, but in
C# there is no such way.

If i click on the Control 'A' itself the Clickevent gets fired so the
code in the parent works also, but i dont know how to fire an event
from within an other event.

What do i have to do to invoke an event in a parent Control from with
in an other event? Any help is appreciated.

Greetings

Jens
 
C

Chris Tacke, eMVP

If I understand correctly this is an analogous situation:

You have a Form with 2 controls, let's say a button and a textbox for this
example. You wire up event handlers for the button click and textbox change
events. Now in the button click handler, you want to fire the textbox
change event? Is that the type of scenario you're after? Do you have the
ability to change the source of the controls?
 
T

Trollpower

Thanks for your reply, Chris

yes, thats exactly what ive meant. But i dont know what "change the
source of the controls" means.

With your described scenario ive got the following:

If i press the Button, the appropriate event on the form fires
correctly. If i change the textbox, it event fires also on the form.
But what i want to do is, if i press the button, i also want the
textbox change event to fire on the form. What do i have to do to let
fire a event manually in c#?

Thanks again

Greetings

Jens
 

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

Similar Threads


Top