Setting MDIParent of new form

Discussion in 'ASP .Net' started by Guest, Oct 8, 2004.

  1. Guest

    Guest Guest

    Hello All,

    Having an issue with setting the MDIParent of a new form.

    I have a form called CMIMain. From this form a child form is opened called
    Form1.

    This is the code I use to set that up:

    Dim Form1 As New Form1
    Form1.MdiParent = Me
    Form1.Show()

    Now, from Form1 I want to open another form called Form2, and I want CMIMain
    to be the parent of Form2 as well. I thought this code would work, but it
    does not:

    Dim Form2 As New Form2
    Form2.MdiParent = CMIMain
    Form2.Show()

    The error I am getting says " 'CMIMain' is a type and cannot be used as an
    expression"

    Any suggestions?

    Thanks!
     
    Guest, Oct 8, 2004
    #1
    1. Advertisements

  2. Guest

    Dave Hall Guest

    Try replacing the problem line with this one:

    Form2.MdiParent = Me.MdiParent

    Dave
     
    Dave Hall, Oct 11, 2004
    #2
    1. Advertisements

  3. Guest

    Chris Jobson Guest

    I'm not well up with VB.NET, but I think:
    Form2.MdiParent = MdiParent
    or, equivalently,
    Form2.MdiParent = Me.MdiParent
    will work.

    Chris Jobson
     
    Chris Jobson, Oct 11, 2004
    #3
  4. Guest

    Guest Guest

    Thanks Dave and Chris.

    That worked!


     
    Guest, Oct 12, 2004
    #4
  5. Guest

    Low_Tech_Gamer_Girl

    Joined:
    May 6, 2012
    Messages:
    1
    Likes Received:
    0
    Thanks

    I just want to say thank you for the help. I found this site while searching for a solution to a similar problem
    :congrats::congrats::congrats::adore:
     
    Low_Tech_Gamer_Girl, May 6, 2012
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.