-
Aug 4th, 2012, 07:42 AM
#1
Thread Starter
Lively Member
Detecting when button is pressed in usercontrol
Hi!
I have a form called Form1.
I have two panels on that form.
I load a usercontrol into one of those panels. That usercontrol contains a series of buttons. I want the form1 to detect when a button is pressed.
Thanks.
-
Aug 4th, 2012, 08:01 AM
#2
Fanatic Member
Re: Detecting when button is pressed in usercontrol
Originally Posted by rqmok
Hi!
I have a form called Form1.
I have two panels on that form.
I load a usercontrol into one of those panels. That usercontrol contains a series of buttons. I want the form1 to detect when a button is pressed.
Thanks.
You would need to add an event handler to each button that when fired will call a method on form1
E.g. Button1.Click += new EventHandler(Form1_Button1_Click);
Something like that. I hope this helps.
-
Aug 4th, 2012, 08:04 AM
#3
Fanatic Member
Re: Detecting when button is pressed in usercontrol
If this isn't possible because of the fact that the buttons are in a user control you may need to use delegates.
http://www.csharp-station.com/Tutorial/CSharp/lesson14
http://www.dreamincode.net/forums/to...n-buttonclick/
-
Aug 5th, 2012, 03:13 AM
#4
Thread Starter
Lively Member
Re: Detecting when button is pressed in usercontrol
Thanks x-ice. I will look into those links.
Meanwhile, if anyone has any other way of doing this then please let me know.
-
Aug 5th, 2012, 03:14 AM
#5
Thread Starter
Lively Member
Re: Detecting when button is pressed in usercontrol
Thanks x-ice. I will look into those links.
Meanwhile, if anyone has any other way of doing this then please let me know.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|