Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Create MDI form in VB.NET?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 19-02-2009
Member
 
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!

Reply With Quote
  #2  
Old 19-02-2009
Member
 
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!
Reply With Quote
  #3  
Old 19-02-2009
Member
 
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()
Reply With Quote
  #4  
Old 19-02-2009
Member
 
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
Reply With Quote
  #5  
Old 19-02-2009
Member
 
Join Date: May 2008
Posts: 2,004
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Create MDI form in VB.NET?"
Thread Thread Starter Forum Replies Last Post
Procedure in VB to create form inside another form Jalabala Software Development 3 16-11-2009 01:14 PM
How to create button on visual C++ Form Ground 0 Software Development 3 14-08-2009 10:26 AM
How to create form in word 2007? Bertus Windows Software 2 29-04-2009 05:48 PM
How to create Form within Form in VB StephanieRice Software Development 2 20-04-2009 01:40 PM
Need to create form in PHP! Bhairav Software Development 6 25-09-2008 01:13 PM


All times are GMT +5.5. The time now is 08:37 AM.