By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Form, form, another form

P: n/a
Form.Owner and Form.Parent, what's the difference between them?

Form.ShowDialog() and Form.Show(), when to use which?

Form.Activated(), what does it mean when saying a Form is "activated"?

Thanks!

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The MSDN library contains a lot of information on those properties and
methods. Here is a quick synopsis:

- Form.Owner is a form that 'owns' this form. When the owner is minimized
or restored, so is this form.

- Form.Parent comes from the fact that a Form is also a control. Every
control can have one parent which is the control with this control inside
it. Usually for a form, this is null.

- Form.ShowDialog() displays the form as a dialog, which means it is stays
on top of the program and code execution stops on the line till the form's
DialogResult property is set (and then is returned).

- Form.Show() simply displays the form normally.

- Form.Activated() brings the form to the top of the screen and gives the
form focus.

Best way to learn more about these is to try them out. Hope this helps.

Cheers,

-Noah Coad
Microsoft MCP & MVP
"fh1996" <fh****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Form.Owner and Form.Parent, what's the difference between them?

Form.ShowDialog() and Form.Show(), when to use which?

Form.Activated(), what does it mean when saying a Form is "activated"?

Thanks!


Nov 15 '05 #2

P: n/a
Noah Coad [MCP & MVP] <no**@coad.net> wrote in message
news:#z**************@TK2MSFTNGP11.phx.gbl...
The MSDN library contains a lot of information on those properties and
methods. Here is a quick synopsis:

- Form.Owner is a form that 'owns' this form. When the owner is minimized
or restored, so is this form.

- Form.Parent comes from the fact that a Form is also a control. Every
control can have one parent which is the control with this control inside
it. Usually for a form, this is null.

- Form.ShowDialog() displays the form as a dialog, which means it is stays
on top of the program and code execution stops on the line till the form's
DialogResult property is set (and then is returned).

- Form.Show() simply displays the form normally.

- Form.Activated() brings the form to the top of the screen and gives the
form focus.

Best way to learn more about these is to try them out. Hope this helps.

Cheers,

-Noah Coad
Microsoft MCP & MVP


Thanks!

If in a button's click method of FormA, FormB is craeted:

FormB f = new FormB();
f.ShowDialog();

Then, what's the relatioship between FormA and FormB?
Nov 15 '05 #3

P: n/a
Sam
In this example, none.

However the usual method of calling ShowDialog is as
follows...

FormB f = new FormB();
f.ShowDialog(this);

In this case FormB.Owner will equal FormA

As mentioned previously, .Parent is almost always null
unless the form is embedded within another control (which
is possible)

Sam
-----Original Message-----

If in a button's click method of FormA, FormB is craeted:

FormB f = new FormB();
f.ShowDialog();

Then, what's the relatioship between FormA and FormB?
.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.