User Control sample program

Posted by Srikrishna777 under C# on 3/12/2010 | Views : 9317 | Status : [Member] | Replies : 2

I am trying to do a sample program on user control.But,I am stuck at the middle while doing.Can any one pls tell me how to go ahead..

My Scenario: I have created a user control which is having two text boxes and two buttons Add,Sub.
I have added this usercontrol project dll to the two winform projects.One is Test1 and Test2.In these two projects,I have added my
user control on the two forms.Now,I want to execute any of the test projects to perform Add and sub operations.But,I want to write the logic for Add and Sub methods in the
user control itself.
1)I know that ,we need to do it with the delegates and events,But dont know how..
2)when I am trying to select the Add button on the Test1 form,I am not able to select that button.Instead,the total user control is getting selected.In this case,how can I write the code here..?

Can anyone tell me how to do the above two points?

M.Srikrishna Murthy


Posted by: Abhi2434 on: 3/12/2010 [Member] [Microsoft_MVP] [MVP] Silver


exposing an event is not actually a big deal... Try my implementation which is in my blog :

Well, if you have built a control, you cant select the individual control from it. So if you want to reposition your control from the application which it uses, expose some properties from the user control which will set the top / left of the button.


Srikrishna777, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 3/26/2010 [Member] Bronze


Check following Links


Srikrishna777, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response