views:

197

answers:

1

I have a parent form and a child form. I need to open the child form at the beginning of a method, do some pretty intensive tasks and then close the child form upon completion.

Here is basically what I've tried so far (with no luck):

Parent Form:

Child child = new Child();

Method()
{
    child.ShowDialog();

    //Method code here

    child.CloseScan();
}

Child Form:

public void CloseScan()
{
    this.Close();
}
+2  A: 

When you call child.ShowDialog(), the code will halt at that point until the dialog is closed, since you're telling it to function as a modal dialog.

If you want to have the code continue to run, you need to use child.Show(this); instead. You can then do your "method code" and close the window afterwards. (Adding "this" causes the form to be a child form of the current form...)

Reed Copsey
Thank you very much. That kind of what I figured but I never even thought of using "Show(this)". I feel dumb now. Thanks again.
Nate Shoffner