如何链接不同的表格?

时间:2009-05-01 15:00:08

标签: c# winforms show showdialog

我在第一个问题上得到了很大的帮助,希望有人会告诉我或者提前找一个关于这个主题的问题。

我希望链接不同的表单,例如我点击第一个按钮,然后打开第二个。基本上我会为手机功能设置菜单,如SMS,CALL等。所以我想要如果我点击通话,则会打开一个新表格,要求拨打号码等。

2 个答案:

答案 0 :(得分:3)

var otherForm = new Form2();
otherForm.ShowDialog(); // To show a modal dialog, or...
otherForm.Show();  // To show it as a non-modal window

答案 1 :(得分:3)

void SomeInitializationFunction() {
      button.Click += new System.EventHandler(buttonClick);
}

private void buttonClick(object sender, System.EventArgs e)
{
    using(GetNumberForm getNumberForm = new GetNumberForm())
    {
        if(DialogResult.OK == getNumberForm.ShowDialog())
        {
            string phoneNumber = getNumberForm.PhoneNumber;
            // do something with the user input.
        }
    }
}