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
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
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.
ASKER
Please do I have no idea how to do that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Apologies a type there on the renaming:
On constructing the custom control:
YourCustomControlInstance. SampleEven t+= new YourCustomControl.SampleDe legate(Pro cedureToBe CalledOnEv entFired);
Basically you assign the event to an instance of the control.
On constructing the custom control:
YourCustomControlInstance.
Basically you assign the event to an instance of the control.
grr. Type above = typo. Yet another typo lol.
ASKER
Thanks man, it worked perfectly!! Thanks for explaining it in the detail you did as well.
Glad I could help.