gpt4 book ai didi

c# - 在 C# 中从另一个 Button 调用代码

转载 作者:太空宇宙 更新时间:2023-11-03 18:16:10 24 4
gpt4 key购买 nike

我需要知道是否可以从另一个按钮调用点击按钮。

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
}

关于c# - 在 C# 中从另一个 Button 调用代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5985378/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com