Calling A Button OnClick from a function

后端 未结 3 1711
误落风尘
误落风尘 2021-01-22 13:39

I have a button with OnClick=Button_Click. I want to call Button_Click from another function but the problem is that I need to give it:

(object sender, EventArgs         


        
3条回答
  •  长情又很酷
    2021-01-22 14:30

    Alternatively, if the action is done primarily by the button, or to avoid extra methods, as of .Net 4.0, there is a function called .PerformClick(). So

    Button.PerformClick();

    Would execute the button click from inside the code.

提交回复
热议问题