问题
I got great help in my first question n hopefully someone will tell me or refer me to an earlier question about this topic.
I want to link different forms like I click on a button on first one and it opens the second one.Basically I'm going to make a Menu for cellphone functions like SMS,CALL etc. so I want that If I click on call a new form opens asking for Number to call etc.
回答1:
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.
}
}
}
回答2:
var otherForm = new Form2();
otherForm.ShowDialog(); // To show a modal dialog, or...
otherForm.Show(); // To show it as a non-modal window
来源:https://stackoverflow.com/questions/811762/how-to-link-different-form