Link to home
Start Free TrialLog in
Avatar of npl77
npl77

asked on

Button Listener C#

I have made a custom control that is a groupbox and has a button (called btnListenToMe) in it. I add lots of these controls to a form (call this frmLayout) at runtime. Now in another form (called frmLaunch) i push a button which opens frmLayout and frmLayout is populated with many of my custom controls.

Now what I want is everytime a btnListenToMe is pushed (remember there are multiple btnListenToMe's on the layout) I want a flag to be thrown to frmLaunch saying a button has been clicked
Avatar of Yiogi
Yiogi

You need an event delegate in your button listener control and have an event assigned from your frmLaunch that creates the control. I can post some code if you don't know how to do that.
Avatar of npl77

ASKER

Please do I have no idea how to do that.
ASKER CERTIFIED SOLUTION
Avatar of Yiogi
Yiogi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Apologies a type there on the renaming:

On constructing the custom control:
                            YourCustomControlInstance.SampleEvent+= new YourCustomControl.SampleDelegate(ProcedureToBeCalledOnEventFired);

Basically you assign the event to an instance of the control.
grr. Type above = typo. Yet another typo lol.
Avatar of npl77

ASKER

Thanks man, it worked perfectly!! Thanks for explaining it in the detail you did as well.
Glad I could help.