Mega Code Archive

 
Categories / VB.Net Tutorial / GUI
 

Add children form to parent form

Imports System.Windows.Forms Imports System.Drawing.Text Imports System.Drawing Imports System.Drawing.Drawing2D public class MDIAddChildToParent    public Shared Sub Main         Application.Run(New Form1)    End Sub End class Public Class Form1     Public mycount As Integer     Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click         Dim i As Integer         Dim newdoc As Form2                     mycount = mycount + 1                   newdoc = New Form2()                    newdoc.Text = "Doc" + Str(mycount)          newdoc.MdiParent = Me                        newdoc.Show()     End Sub     Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click         Me.ActiveMdiChild.Text = Me.ActiveMdiChild.Text     End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1     Inherits System.Windows.Forms.Form     'Form overrides dispose to clean up the component list.     <System.Diagnostics.DebuggerNonUserCode()> _     Protected Overrides Sub Dispose(ByVal disposing As Boolean)         If disposing AndAlso components IsNot Nothing Then             components.Dispose()         End If         MyBase.Dispose(disposing)     End Sub     'Required by the Windows Form Designer     Private components As System.ComponentModel.IContainer     'NOTE: The following procedure is required by the Windows Form Designer     'It can be modified using the Windows Form Designer.       'Do not modify it using the code editor.     <System.Diagnostics.DebuggerStepThrough()> _     Private Sub InitializeComponent()         Me.MenuStrip1 = New System.Windows.Forms.MenuStrip         Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem         Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem         Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem         Me.ToolStripMenuItem4 = New System.Windows.Forms.ToolStripMenuItem         Me.ToolStripMenuItem5 = New System.Windows.Forms.ToolStripMenuItem         Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem         Me.MenuStrip1.SuspendLayout()         Me.SuspendLayout()         '         'MenuStrip1         '         Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem1, Me.ToolStripMenuItem5})         Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)         Me.MenuStrip1.MdiWindowListItem = Me.ToolStripMenuItem5         Me.MenuStrip1.Name = "MenuStrip1"         Me.MenuStrip1.Padding = New System.Windows.Forms.Padding(8, 2, 0, 2)         Me.MenuStrip1.Size = New System.Drawing.Size(569, 24)         Me.MenuStrip1.TabIndex = 2         Me.MenuStrip1.Text = "MenuStrip1"         '         'ToolStripMenuItem1         '         Me.ToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem2, Me.ToolStripMenuItem3, Me.ToolStripMenuItem4})         Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1"         Me.ToolStripMenuItem1.Size = New System.Drawing.Size(49, 20)         Me.ToolStripMenuItem1.Text = "File"         '         'ToolStripMenuItem2         '         Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2"         Me.ToolStripMenuItem2.Size = New System.Drawing.Size(152, 22)         Me.ToolStripMenuItem2.Text = "new"         '         'ToolStripMenuItem3         '         Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3"         Me.ToolStripMenuItem3.Size = New System.Drawing.Size(152, 22)         Me.ToolStripMenuItem3.Text = "save"         '         'ToolStripMenuItem4         '         Me.ToolStripMenuItem4.Name = "ToolStripMenuItem4"         Me.ToolStripMenuItem4.Size = New System.Drawing.Size(152, 22)         Me.ToolStripMenuItem4.Text = "Quit"         '         'ToolStripMenuItem5         '         Me.ToolStripMenuItem5.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem6})         Me.ToolStripMenuItem5.Name = "ToolStripMenuItem5"         Me.ToolStripMenuItem5.Size = New System.Drawing.Size(49, 20)         Me.ToolStripMenuItem5.Text = "Edit"         '         'ToolStripMenuItem6         '         Me.ToolStripMenuItem6.Name = "ToolStripMenuItem6"         Me.ToolStripMenuItem6.Size = New System.Drawing.Size(152, 22)         Me.ToolStripMenuItem6.Text = "rename"         '         'Form1         '         Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font         Me.ClientSize = New System.Drawing.Size(569, 275)         Me.Controls.Add(Me.MenuStrip1)         Me.IsMdiContainer = True         Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)         Me.MenuStrip1.ResumeLayout(False)         Me.MenuStrip1.PerformLayout()         Me.ResumeLayout(False)         Me.PerformLayout()     End Sub     Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip     Friend WithEvents ToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem     Friend WithEvents ToolStripMenuItem2 As System.Windows.Forms.ToolStripMenuItem     Friend WithEvents ToolStripMenuItem3 As System.Windows.Forms.ToolStripMenuItem     Friend WithEvents ToolStripMenuItem4 As System.Windows.Forms.ToolStripMenuItem     Friend WithEvents ToolStripMenuItem5 As System.Windows.Forms.ToolStripMenuItem     Friend WithEvents ToolStripMenuItem6 As System.Windows.Forms.ToolStripMenuItem End Class Public Class Form2     Private Sub Form2_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize         TextBox1.Top = 5         TextBox1.Left = 5         TextBox1.Width = Me.Width - 20         TextBox1.Height = Me.Height - 45     End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form2     Inherits System.Windows.Forms.Form     'Form overrides dispose to clean up the component list.     <System.Diagnostics.DebuggerNonUserCode()> _     Protected Overrides Sub Dispose(ByVal disposing As Boolean)         If disposing AndAlso components IsNot Nothing Then             components.Dispose()         End If         MyBase.Dispose(disposing)     End Sub     'Required by the Windows Form Designer     Private components As System.ComponentModel.IContainer     'NOTE: The following procedure is required by the Windows Form Designer     'It can be modified using the Windows Form Designer.       'Do not modify it using the code editor.     <System.Diagnostics.DebuggerStepThrough()> _     Private Sub InitializeComponent()         Me.TextBox1 = New System.Windows.Forms.TextBox         Me.SuspendLayout()         '         'TextBox1         '         Me.TextBox1.Location = New System.Drawing.Point(12, 12)         Me.TextBox1.Multiline = True         Me.TextBox1.Name = "TextBox1"         Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both         Me.TextBox1.Size = New System.Drawing.Size(294, 166)         Me.TextBox1.TabIndex = 0         '         'Form2         '         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font         Me.ClientSize = New System.Drawing.Size(318, 190)         Me.Controls.Add(Me.TextBox1)         Me.ResumeLayout(False)         Me.PerformLayout()     End Sub     Friend WithEvents TextBox1 As System.Windows.Forms.TextBox End Class