How to call method in user control to form1
can someone help mi with these??
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 19, 2010, 10:53 PM EST
It's easy.
1. First you create a usercontrol and write a public method inside that class.
2. Then from your windows application project, you add a refernce to this usercontrol project.
3. Then you can see the user control in the toolbox of your windows application project.
4. You drag a usercontrol to your form. What this actually does is adding a Usercontrol object to your form class.
5. Then you check the name of the usercontrolobject added to the form. You can check this name by looking at the property window of the usercontrol added.
6. Then in the form, you can call the method as below.
usercontrolobjectname.Methodname();
Check my code. I have done the same thing in my code. You will easily understand what I say.
Please do not forget to tick 'Do you like this answer' checkbox, if this helps you.
Santhosh NRank #4,788 · 325 reputationPosted Jan 19, 2010, 10:32 PM EST
uc1.publicmethod(..)
Lalit MRank #1,186 · 1.5K reputationPosted Jan 19, 2010, 10:48 PM EST
public void Test1_fillPageType()
{
Test1.fillPageType();
}
/*** wucCourseContent.ascx.cs ***/
WucMainPage1.Test1_fillPageType();