Results 1 to 5 of 5

Thread: [RESOLVED] Adding ChildForms

  1. #1

    Thread Starter
    Hyperactive Member Tarablue's Avatar
    Join Date
    Feb 2007
    Location
    Somewhere West of GMT
    Posts
    398

    Resolved [RESOLVED] Adding ChildForms

    Hello All,

    I'm running VB.Net 2005

    How does one add a ChildForm to a parent form. The documentation I have states:-

    'Create a new form and set it's IsMDIContainer property to True.'

    Done that!

    'Next, create a child form class to be added to the form. To do this, right-click the project in the Solution Explorer, select Add Windows Form and name the file.'

    Done that, I think!

    Now here's where I get lost. It then goes on to say, 'to add the child form to the parent, you must create a new child form object, set it's MDIParent to the parent form'

    HOW?

    Best Rgds,
    Tarablue
    Last edited by Tarablue; Jan 11th, 2008 at 07:21 PM.

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: Adding ChildForms

    Code:
    Dim ChildForm As New Form2
    ChildForm.MdiParent = Me
    ChildForm.Show()
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  3. #3

    Thread Starter
    Hyperactive Member Tarablue's Avatar
    Join Date
    Feb 2007
    Location
    Somewhere West of GMT
    Posts
    398

    Re: Adding ChildForms

    Hello bmahler,

    I place this code thus:-
    Code:
    Public Class Form1
    
        Dim ChildForm As New Form2
        ChildForm.MdiParent = me
        ChildForm.Show()
    
    
    End Class
    right? but that doesn't work. Line one goes in OK but lines 2 & 3 give an error 'Declaration Expected'. Also, ChildForm in both lines is underlined with a blue squiggle.

    There must be something that I'm not doing right.

    Rgds,
    Tarablue

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Adding ChildForms

    That code has to go inside a method. If you want it done when the form gets loaded then you put it inside the form's Load event handler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member Tarablue's Avatar
    Join Date
    Feb 2007
    Location
    Somewhere West of GMT
    Posts
    398

    Re: Adding ChildForms

    Hello jmcihinney & bmahler,

    Got It!!

    Thanks a lot guys.

    Rgds,
    Tarablue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width