
怎么在一个窗体按下一个按钮调用另一个窗体的按钮的事件
2个回答
展开全部
将被调用的窗体加个timer, 并将其Modifiers属性改为public, 写下如下代码:
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click(this, null);
timer1.Enabled = false;
}
}
调用窗体写下以下代码即可:
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.timer1.Enabled = true;
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click(this, null);
timer1.Enabled = false;
}
}
调用窗体写下以下代码即可:
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
f.timer1.Enabled = true;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询