[ACCEPTED]-C# ShowDialog Parent Form is null-forms

Accepted answer
Score: 23

You should check the Owner instead of the Parent

What 6 you're setting in the constructor of ShowDialog 5 is the Owner property. Which tells the form 4 which other form "owns" it. The parent is 3 (as indicated by Mario) described the ownership 2 relationship for a Control.

so you should 1 change your code to:

if (this.Owner == null)
  {
    var sc = new ScanCheck();
    sc.Show();
    this.Hide();
  }

and it should work.

Score: 4

Parent is a property inherited from control 5 which is used to describe embedding relationships 4 ( a label has as parent the form).

I do not 3 think it is set when using ShowDialog().

I 2 assume that Owner is the correct property 1 to check.

hth

Mario

Score: 0

Since you are passing DisplayDataForm as parent in lw.ShowDialog(this); DisplayDataForm 2 is the parent of LoadWorkstationFile form 1 when calling it second time.

More Related questions