Results 1 to 5 of 5

Thread: Create MDI form in VB.NET?

  1. #1
    Join Date
    Feb 2009
    Posts
    8

    Create MDI form in VB.NET?

    Hi,

    I want to create MDI form in VB.NET through code!

    Please help me!

  2. #2
    Join Date
    May 2008
    Posts
    63

    Re: Create MDI form in VB.NET?

    MDI (Multiple Document Interface) Application is an application in which we can view and work with several documents at once. Example of an MDI application is Microsoft Excel. Excel allows us to work with several documents at once. In contrast, SDI (Single Document Interface) applications are the applications which allows us to work with a single document at once. Example of a single document application is Microsoft Word in which only one document is visible at a time.

    Open a new Windows Application in Visual Basic .NET. The application will open with a default form, Form1. Add another form, Form2 to this application by right-clicking on the project name in Solution Explorer window and selecting Add->Add Windows Form. You can add some controls to Form2. For this application we will make From1 as the MDI parent window and Form2 as MDI child window. MDI child forms are important for MDI Applications as users interact mostly through child forms. Select Form1 and in it's Properties Window under the Windows Style section, set the property IsMdiContainer to True. Setting it to true designates this form as an MDI container for the child windows. Once you set that property to true the form changes it's color. Now, from the toolbox drag a MainMenu component onto Form1. ame the top-level menu item to File with submenu items as New Child Window, Arrange Child Windows and Exit.

    With this application a new child window is displayed each time the New Child Window menu item is clicked, all child windows will be arranged when you click Arrange Child Windows menu item.

    Code:
    Public Class Form1 Inherits System.Windows.Forms.Form
    
    Dim childForm As Integer = 0
    Dim childForms(5) As Form2
    'declaring an array to store child windows
    'five child windows (Form2) will be displayed
    
    #Region " Windows Form Designer generated code "
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e _
    As System.EventArgs) Handles MyBase.Load
    End Sub
    
    Private Sub MenuItem2_Click(ByVal sender As System.Object,_
    ByVal e As System.EventArgs) Handles MenuItem2.Click
    childForm += 1
    childForms(childForm) = New Form2()
    childForms(childForm).Text = "ChildForm" & Str(childForm)
    'setting title for child windows and incrementing the number with an array
    childForms(childForm).MdiParent = Me
    childForms(childForm).Show()
    End Sub
    
    Private Sub MenuItem3_Click(ByVal sender As System.Object,_
    ByVal e As System.EventArgs) Handles MenuItem3.Click
    Me.LayoutMdi(MdiLayout.Cascade)
    'arranging child windows on the parent form with predefined LayoutMdi method
    'Different layouts available are, ArrangeIcons, Cascade, TileHorizontal, TileVertical
    End Sub
    
    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal_
    e As System.EventArgs) Handles MenuItem4.Click
    Me.Close()
    'closing the application
    End Sub
    
    End Class
    For further information on MDI forms!

  3. #3
    Join Date
    Jun 2008
    Posts
    144

    Re: Create MDI form in VB.NET?

    To make the MDI container form, make a form and set its IsMdiContainer property to True.

    To make a menu list the MDI child forms, set its MdiList property to True.

    Use code similar to the following to add a MDI child form to the MDI container.

    Code:
    Dim frm2 As New Form2
    frm2.MdiParent = Me
    frm2.Text = "Child " & Me.MdiChildren.GetLength(0)
    frm2.Show()

  4. #4
    Join Date
    Jun 2008
    Posts
    97

    Re: Create MDI form in VB.NET?

    I this this will also help you in further changes for your MDI form & creating Child forms

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Create MDI form in VB.NET?

    Creates an MDI application which consists of a main "parent" form and a child form.

    Code:
    Imports System
    Imports System.Windows.Forms
    
    Public Module AppModule
       Public Sub Main()
          Application.Run(New MainForm())
       End Sub
    End Module
    
    Public Class MainForm
       Inherits Form
       
       Public Sub New()
          ' Set parent window caption.
          Text = "Main Parent Window"
          ' Set this to be an MDI parent form.
          IsMdiContainer = True
          ' Create a child form.
          Dim myChild As New DocumentForm("My Document", Me)
          myChild.Show
       End Sub
    
    End Class
    
    Public Class DocumentForm
       Inherits Form
       
       Public Sub New(ByVal name As String, ByVal parent As Form)
          ' Set the child window caption.
          Text = name
          ' Set this to be an MDI child form.
          MdiParent = parent
       End Sub
       
    End Class

Similar Threads

  1. 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
  2. How to create button on visual C++ Form
    By Ground 0 in forum Software Development
    Replies: 3
    Last Post: 14-08-2009, 10:26 AM
  3. How to create form in word 2007?
    By Bertus in forum Windows Software
    Replies: 2
    Last Post: 29-04-2009, 05:48 PM
  4. How to create Form within Form in VB
    By StephanieRice in forum Software Development
    Replies: 2
    Last Post: 20-04-2009, 01:40 PM
  5. Need to create form in PHP!
    By Bhairav in forum Software Development
    Replies: 6
    Last Post: 25-09-2008, 01:13 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,238,368.39128 seconds with 17 queries