Hello, everyone:

I have a dialog form need to initial some data from its ParentForm, but I can not get its ParentForm. what I have done is:

when I click one button1 on Form1, it does:
{
dialog d=new dialog();
d.ShowDialog();
}

in the Dialog form, after initialize the components, even I check its ParentForm
if(this.ParentForm==null)
{
MessageBox.Show("no parent form");
}

I always get "no parent form".

Could anyone tell me what's wrong I have done?

Sincerely,

Haiwen

Re: Can not get dialog's ParentForm?? by Lloyd

Lloyd
Thu Jul 15 18:24:08 CDT 2004

In the ShowDialog call use the overloaded version that allow you to input a
form. ie d.ShowDialog(me)

That will set the parent.

Lloyd Sheen
"haiwen" <haiwen@discussions.microsoft.com> wrote in message
news:7AD522CD-6FED-4886-8109-54962614423A@microsoft.com...
> Hello, everyone:
>
> I have a dialog form need to initial some data from its ParentForm, but I
can not get its ParentForm. what I have done is:
>
> when I click one button1 on Form1, it does:
> {
> dialog d=new dialog();
> d.ShowDialog();
> }
>
> in the Dialog form, after initialize the components, even I check its
ParentForm
> if(this.ParentForm==null)
> {
> MessageBox.Show("no parent form");
> }
>
> I always get "no parent form".
>
> Could anyone tell me what's wrong I have done?
>
> Sincerely,
>
> Haiwen



Re: Can not get dialog's ParentForm?? by Shakir

Shakir
Thu Jul 15 18:32:50 CDT 2004

ParentForm will return the parent of MdiChild forms

Form myChild = new Form();
myChild.MdiParent = this;

Inside myChild Form you can get parent form.

string parentname = myChild.ParentForm.Name

--
Shak
(Houston)


"haiwen" <haiwen@discussions.microsoft.com> wrote in message
news:7AD522CD-6FED-4886-8109-54962614423A@microsoft.com...
> Hello, everyone:
>
> I have a dialog form need to initial some data from its ParentForm, but I
can not get its ParentForm. what I have done is:
>
> when I click one button1 on Form1, it does:
> {
> dialog d=new dialog();
> d.ShowDialog();
> }
>
> in the Dialog form, after initialize the components, even I check its
ParentForm
> if(this.ParentForm==null)
> {
> MessageBox.Show("no parent form");
> }
>
> I always get "no parent form".
>
> Could anyone tell me what's wrong I have done?
>
> Sincerely,
>
> Haiwen



Re: Can not get dialog's ParentForm?? by haiwen

haiwen
Fri Jul 16 09:43:01 CDT 2004

Hello, Shakir and Lloyd:

Thank you for your reply.

For MDI form, "myChild.MdiParent = this" does work, but my problem is I can not get the parentForm from the dialog. Even I try follow:

dialog d=new dialog();
d.ShowDialog(this); //it seems this is owner,not parentForm

from the dialog form:

if(this.ParentForm==null )

still true, of course, this.Owner is not equal null.

I just wonder why ParentForm does not work in dialog?

Thanks again.

Sincerely,

Haiwen


this.


"Shakir Hussain" wrote:

> ParentForm will return the parent of MdiChild forms
>
> Form myChild = new Form();
> myChild.MdiParent = this;
>
> Inside myChild Form you can get parent form.
>
> string parentname = myChild.ParentForm.Name
>
> --
> Shak
> (Houston)
>
>
> "haiwen" <haiwen@discussions.microsoft.com> wrote in message
> news:7AD522CD-6FED-4886-8109-54962614423A@microsoft.com...
> > Hello, everyone:
> >
> > I have a dialog form need to initial some data from its ParentForm, but I
> can not get its ParentForm. what I have done is:
> >
> > when I click one button1 on Form1, it does:
> > {
> > dialog d=new dialog();
> > d.ShowDialog();
> > }
> >
> > in the Dialog form, after initialize the components, even I check its
> ParentForm
> > if(this.ParentForm==null)
> > {
> > MessageBox.Show("no parent form");
> > }
> >
> > I always get "no parent form".
> >
> > Could anyone tell me what's wrong I have done?
> >
> > Sincerely,
> >
> > Haiwen
>
>
>