Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Is there a MDIParent for Modal form.

riyazcriyazc Member Posts: 2
Hi,

I have a main MDI Form and rest of forms open under it. On load of this form i am showing a [b]frmMsg [/b]which is opened using [b]frmMsg.ShowDialog()[/b], which means that frmMsg will be behave like a modal form.
code
frmMsg frmMessageNew = new frmMsg();
frmMessageNew.MdiParent = this.MdiParent;
frmMessageNew.ShowDialog();

Now on frmMsg i have a button by clicking on it i load another form [b]frmNewMessage [/b] as

frmNewMessage ChildForm = new frmNewMessage();
ChildForm.MdiParent = this.MdiParent;
ChildForm.Show();

But ChildForm (i.e. frmNewMessage) fails to open inside MDI form. It is not able to find the MDI parent form.

does any one knows how to do this.
thanks.

Comments

  • bradwangbradwang Member Posts: 197
    : Hi,
    :
    : I have a main MDI Form and rest of forms open under it. On load of
    : this form i am showing a [b]frmMsg [/b]which is opened using
    : [b]frmMsg.ShowDialog()[/b], which means that frmMsg will be behave
    : like a modal form.
    : code
    : frmMsg frmMessageNew = new frmMsg();
    : frmMessageNew.MdiParent = this.MdiParent;
    : frmMessageNew.ShowDialog();
    :
    : Now on frmMsg i have a button by clicking on it i load another form
    : [b]frmNewMessage [/b] as
    :
    : frmNewMessage ChildForm = new frmNewMessage();
    : ChildForm.MdiParent = this.MdiParent;
    : ChildForm.Show();
    :
    : But ChildForm (i.e. frmNewMessage) fails to open inside MDI form. It
    : is not able to find the MDI parent form.
    :
    : does any one knows how to do this.
    : thanks.


    frmMsg frmMessageNew = new frmMsg();
    [b]frmMessageNew.MdiParent = this.MdiParent;[/b] This line of code, should it be frmMessageNew.MdiParent = this; ??
    frmMessageNew.ShowDialog();


    [color=Green][size=1][b]Brad Wang - .NET Freelancer from China
    MSN: brad_wang_cn@hotmail.com
    Skype: brad_wang[/b][/size][/color]
  • riyazcriyazc Member Posts: 2
    Yes...got the solution...
    here's wat i did.

    On MDI FormLoad
    {

    frmMyMessage childForm = new frmMyMessage();
    childForm.Text = "Select Project";
    childForm.Owner = this;
    childForm.ShowDialog();
    }

    Now on frmMyMessage button click i used
    private void button1_Click(object sender, EventArgs e)
    {
    frmPublisher frmPub = new frmPublisher();
    frmPub.MdiParent = this.Owner;
    this.Dispose();
    frmPub.Show();
    }

    Form shown as a modal popup cannot have a parent form defined as they are top most forms.By setting the Form.Owner = this for the modal form we can specify the owner/parent for the form.

    thanks for replying :)


Sign In or Register to comment.