Results 1 to 3 of 3

Thread: How to create Form within Form in VB

  1. #1
    Join Date
    Apr 2009
    Posts
    64

    How to create Form within Form in VB

    Hello all,

    As per my knowledge, I have checked an application which has the form within form.
    Is it possible to have what i have suggested please provide me some more details regarding it. and if this is possible then the inner window should not go out of the main frame window.

    Have anyone come across this Before?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Posts
    211

    Re: How to create Form within Form in VB

    The first step in creating an MDI form is to create the parent form. Begin by launching Visual Studio and creating a new Windows Application project named vbMDI. The new project will contain a single form. Change the name of this form in the Properties panel to MDIparent. Also in the Properties panel, change the IsMdiContainer property to True. You will notice that the form background changes to dark grey, the default for MDI containers. This form is now ready to act as the container for the child forms.

    Edit the properties of the two new forms so that the title texts are Child Form 1 and Child Form2 respectively. Also, use the properties panel to name the forms MDIchild1 and MDIchild2.

    The next step is to add the two new forms (MDIchild1 and MDIchild2) to the parent form (MDIparent). To do this click on the tab for the parent form in Visual Studio and double click on the form to display the event procedures. We will now write Visual Basic code to add the two child forms to the container parent form. To do this we will set the MdiParent property of each child to reference the MDIparent form. Note that because this is the Load event of the actual parent form, we refer to it with the keyword Me rather than by the form name. Having set the Mdiparent of each child we then need to display the form using the form Show() method:

    Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            MDIchild1.MdiParent = Me
            MDIchild1.Show()
            MDIchild2.MdiParent = Me
            MDIchild2.Show()
    End Sub

  3. #3
    Join Date
    Dec 2008
    Posts
    202

    Re: How to create Form within Form in VB

    in either version of Visual Basic, are essentially the same as any other class; they have properties, methods, and events, and you can create multiple instances of them. So, assuming you have a form in your project called Form2, the Visual Basic 6.0 code shown here creates three instances of that form and displays them all:

    Code:
    Dim myFirstForm As Form2
    Dim mySecondForm As Form2
    Dim myThirdForm As Form2
    
    Set myFirstForm = New Form2
    Set mySecondForm = New Form2
    Set myThirdForm = New Form2
    
    myFirstForm.Show
    mySecondForm.Show
    myThirdForm.Show
    Now, other than the use of the keyword Set to assign new Form2 instances to your three variables, this code will also work in Visual Basic .NET

Similar Threads

  1. Replies: 5
    Last Post: 25-05-2011, 10:21 PM
  2. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  3. How to Auto Populate fields from sub form to form?
    By mich43 in forum Windows Software
    Replies: 6
    Last Post: 09-11-2010, 11:29 PM
  4. Procedure in VB to create form inside another form
    By Jalabala in forum Software Development
    Replies: 3
    Last Post: 16-11-2009, 02:14 PM
  5. Problem reloading MDI child form in main form.
    By AFFAN in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,575,406.32346 seconds with 17 queries