C# Click button Without clicking manually

前端 未结 2 1739
后悔当初
后悔当初 2020-12-12 05:08

Just want to click accept button inside source without clicking it manually on form

And hide the form to the user

Form will come with accept=ok and gonna be hi

相关标签:
2条回答
  • 2020-12-12 05:34

    You can use PerformClick Method:

    button1.PerformClick();
    
    0 讨论(0)
  • 2020-12-12 05:39

    If you are talking about clicking, most probably you have event handler, which simply you want to invoke. I suppose it is OnAcceptClick .

    So to achieve your goal simply invoke the method just like any other:

    OnAcceptClick(null, null);
    

    As first argument, you can pass reference to your accept button and if you need event arguments, you can create new instance of it as needed.

    0 讨论(0)
提交回复
热议问题