C# 在C中从另一个按钮调用按钮的代码#
我需要知道是否可以调用另一个按钮的点击C# 在C中从另一个按钮调用按钮的代码#,c#,.net,button,click,action,C#,.net,Button,Click,Action,我需要知道是否可以调用另一个按钮的点击 private void myAction_Click(object sender, EventArgs e) { // int x; // ... } private void Go_Click(object sender, EventArgs e) { // call the myAction_Click button } 谢谢。您想要: private void Go_Click(object sender, EventA
private void myAction_Click(object sender, EventArgs e)
{
// int x;
// ...
}
private void Go_Click(object sender, EventArgs e)
{
// call the myAction_Click button
}
谢谢。您想要:
private void Go_Click(object sender, EventArgs e)
{
myAction_Click(sender, e);
}
但更好的设计是将代码拉出:
private void myAction_Click(object sender, EventArgs e)
{
DoSomething();
}
private void Go_Click(object sender, EventArgs e)
{
DoSomething();
}
private void DoSomething()
{
// Your code here
}
该按钮具有PerformClick方法
谢谢,伙计,我想我会把代码放在另一个函数中,在两个按钮中调用。为什么要让另一个按钮点击?