將被呼叫的窗體加個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;
呼叫窗體寫下以下程式碼即可:
Form2 f = new Form2();
f.timer1.Enabled = true;
將被呼叫的窗體加個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;
}