Windows ShowDialog method is failing.

B

Brian 5

I am having a problem here when I try to call ShowDialog(IWin32Window
owner) method from the form. I get this error :


showDialog tried to set an ineligible form as owner. Forms cannot own
themselves or their owners.
Parameter name: owner : System.ArgumentException
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)


In my method call:


objectForm.ShowDialog(callingViewer.ParentForm)


objectForm has just been instantiated a couple of lines prior. And at
the time the line is executed, objectForm has no Owner or Parent and
because it had just been instantiated and nothing more done to it,
objectForm can't possibly be the Owner or Parent of the
callingViewer.ParentForm nor is it the same object as
callingViewer.ParentForm. So it is not reconcilable that objectForm is

attempting to set itself as the Owner nor can callingViewer.ParentForm
have objectForm as its owner because at this point in the code,
callingViewer.ParentForm has an Owner that is a completely different
form. I have heard that if the Form's TopMost property is set to true
that this problem can be created. But I checked and neither form has a

TopMost property set to true. Anybody have any ideas as to what's
wrong here?
 
C

Chris Dunaway

Brian said:
objectForm has just been instantiated a couple of lines prior. And at
the time the line is executed, objectForm has no Owner or Parent and

Can you show us how it was instantiated? What if you place a
breakpoint on the ShowWindow line and inspect the parent, and owner
properties of each form?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top