窗口形式的三个按钮打开相同的另一种形式

时间:2016-05-15 15:08:48

标签: c# .net winforms

我在窗口表单中有三个按钮可以打开3个不同的表单,但这些表单是打开的,只能由button1打开。

public partial class Home : Form
{
    public Home()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Task addnew = new Task();
        addnew.Show();
    }
    private void button2_Click(object sender, EventArgs h)
    {
        Task History = new Task();
        History.Show();
    }
    private void button3_Click(object sender, EventArgs v)
    {
        Task Evaluate = new Task();
        Evaluate.Show();
    }
}

1 个答案:

答案 0 :(得分:1)

如果您的表单名称为TaskHistoryEvaluate,请在三种方法中初始化您的三个

 public partial class Home : Form 
 { 
    public Home() 
    { 
      InitializeComponent(); 
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Task addnew = new Task();
        addnew.Show();
    }
    private void button2_Click(object sender, EventArgs h)
    {
        History history = new History();
        history.Show();
     }
    private void button3_Click(object sender, EventArgs v)
    {
        Evaluate evaluate = new Evaluate();
        evaluate.Show();
    }
 }