Reputation: 1396
I have a MainForm
Class Instance,
I bring up another form like so;
InputForm MyInput= new InputForm("Enter a Number");
MyInput.ShowDialog();
I close MyInput
form from within itself like this;
private void Button_Click(object sender, EventArgs e)
{
//Do things here
this.Hide();
}
Flow resumes in the MainForm and using either
this.Show();
or
this.Activate();
neither will consistantly bring the MainForm
to the front.
How can I do this?
Upvotes: 0
Views: 137
Reputation: 54532
What you need to do is show your InputForm like this. This form of ShowDialog assigns the owner to your dialogbox.
DialogResult dr = MyInput.ShowDialog(this);
//test for result here
MyInput.Close();
Upvotes: 2
Reputation: 2760
this.Hide()
appears to be hiding the main form, not the input. Because ShowDialog
is a blocking method, the InputForm will need to be closed by user action, code internal to the InputForm, or by another thread.
Upvotes: 0