How to call mainform method in another form in usercontrol C#

前端 未结 5 2090
长发绾君心
长发绾君心 2020-12-22 11:19

I am working with windowsFrom in c#. I am trying to call mainfrom method in one of the from in user control. I have mainfrom like this

namespace Project
{
          


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 11:43

    Try this:

    From user control try this:

    MainForm form = this.TopLevelControl as MainForm;
    form.TempCommand();
    

提交回复
热议问题