views:

1220

answers:

2

I have an MDIChild form that needs to show a dialog. I'm currently doing it like this from inside the mdichild form...

f.ShowDialog(Me)

Should I be using f.ShowDialog(mdiparent)?

What is the difference when setting the owner before calling showdialog()?

Thanks.

+2  A: 

I'm not sure if this is related, but I've had some issues with passing the owning form in ShowDialog, I usually do this:

f.Owner = Me
f.ShowDialog()
Joey
I will see if it makes a difference.
dotjoe
+2  A: 

The difference is in which parent owns the dialog. If you explicitly set the parent then that window owns the dialog. If you don't set it (using the parameterless version of ShowDialog) then the current active window of your application owns the dialog. That's on MSDN, btw.

Where this is useful is in centering your dialog by setting the StartPosition property using the FormStartPosition.CenterParent enumeration.

Chris Holmes
I guess you would have to do some trickery for the current active window to NOT be the "parent"...unless you trigger a showdialog from another forms action, which would be weird.
dotjoe