Imports System.Windows.Forms
public class RadioButtonCheckBox
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class MDIChild
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.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.
Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents mnuMDIOptions As System.Windows.Forms.MenuItem
Friend WithEvents mnuMDIOpiton1 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMDIOpiton2 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMDIOpiton3 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.RichTextBox1 = New System.Windows.Forms.RichTextBox()
Me.mainMenu1 = New System.Windows.Forms.MainMenu()
Me.mnuMDIOptions = New System.Windows.Forms.MenuItem()
Me.mnuMDIOpiton1 = New System.Windows.Forms.MenuItem()
Me.mnuMDIOpiton2 = New System.Windows.Forms.MenuItem()
Me.mnuMDIOpiton3 = New System.Windows.Forms.MenuItem()
Me.SuspendLayout()
"
"RichTextBox1
"
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Size = New System.Drawing.Size(296, 176)
Me.RichTextBox1.TabIndex = 0
Me.RichTextBox1.Text = "RichTextBox1"
"
"mainMenu1
"
Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMDIOptions})
"
"mnuMDIOptions
"
Me.mnuMDIOptions.Index = 0
Me.mnuMDIOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMDIOpiton1, Me.mnuMDIOpiton2, Me.mnuMDIOpiton3})
Me.mnuMDIOptions.MergeOrder = 1
Me.mnuMDIOptions.Text = "MDIChildOptions"
"
"mnuMDIOpiton1
"
Me.mnuMDIOpiton1.Index = 0
Me.mnuMDIOpiton1.Text = "MDI Option 1"
"
"mnuMDIOpiton2
"
Me.mnuMDIOpiton2.Index = 1
Me.mnuMDIOpiton2.Text = "MDI Option 2"
"
"mnuMDIOpiton3
"
Me.mnuMDIOpiton3.Index = 2
Me.mnuMDIOpiton3.Text = "MDI Option 3"
"
"MDIChild
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 174)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1})
Me.Menu = Me.mainMenu1
Me.Name = "MDIChild"
Me.Text = "MDIChild"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuMDIOpiton1.Click, mnuMDIOpiton2.Click, mnuMDIOpiton3.Click
Dim item As MenuItem = CType(sender, MenuItem)
item.Checked = Not item.Checked
End Sub
End Class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
"This call is required by the Windows Form Designer.
InitializeComponent()
"Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.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.
Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
Friend WithEvents mnuNew As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileOpen As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileClose As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileSave As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileSaveAs As System.Windows.Forms.MenuItem
Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem
Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem
Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem
Friend WithEvents mnuOptions As System.Windows.Forms.MenuItem
Friend WithEvents mnuOption1 As System.Windows.Forms.MenuItem
Friend WithEvents mnuOption2 As System.Windows.Forms.MenuItem
Friend WithEvents mnuOption3 As System.Windows.Forms.MenuItem
Friend WithEvents mnuRadioOptions As System.Windows.Forms.MenuItem
Friend WithEvents mnuRadioOption1 As System.Windows.Forms.MenuItem
Friend WithEvents mnuRadioOption2 As System.Windows.Forms.MenuItem
Friend WithEvents mnuRadioOption3 As System.Windows.Forms.MenuItem
Friend WithEvents mnuWindow As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu1 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu11 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu12 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu13 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu14 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMerge As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu2 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu21 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu22 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu23 As System.Windows.Forms.MenuItem
Friend WithEvents mnuMenu24 As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.mainMenu1 = New System.Windows.Forms.MainMenu()
Me.mnuFile = New System.Windows.Forms.MenuItem()
Me.mnuNew = New System.Windows.Forms.MenuItem()
Me.mnuFileOpen = New System.Windows.Forms.MenuItem()
Me.mnuFileClose = New System.Windows.Forms.MenuItem()
Me.mnuFileSave = New System.Windows.Forms.MenuItem()
Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem()
Me.mnuEdit = New System.Windows.Forms.MenuItem()
Me.mnuEditCopy = New System.Windows.Forms.MenuItem()
Me.mnuEditPaste = New System.Windows.Forms.MenuItem()
Me.mnuOptions = New System.Windows.Forms.MenuItem()
Me.mnuOption1 = New System.Windows.Forms.MenuItem()
Me.mnuOption2 = New System.Windows.Forms.MenuItem()
Me.mnuOption3 = New System.Windows.Forms.MenuItem()
Me.mnuRadioOptions = New System.Windows.Forms.MenuItem()
Me.mnuRadioOption1 = New System.Windows.Forms.MenuItem()
Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem()
Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem()
Me.mnuWindow = New System.Windows.Forms.MenuItem()
Me.mnuMenu1 = New System.Windows.Forms.MenuItem()
Me.mnuMenu11 = New System.Windows.Forms.MenuItem()
Me.mnuMenu12 = New System.Windows.Forms.MenuItem()
Me.mnuMenu13 = New System.Windows.Forms.MenuItem()
Me.mnuMenu14 = New System.Windows.Forms.MenuItem()
Me.mnuMerge = New System.Windows.Forms.MenuItem()
Me.mnuMenu2 = New System.Windows.Forms.MenuItem()
Me.mnuMenu21 = New System.Windows.Forms.MenuItem()
Me.mnuMenu22 = New System.Windows.Forms.MenuItem()
Me.mnuMenu23 = New System.Windows.Forms.MenuItem()
Me.mnuMenu24 = New System.Windows.Forms.MenuItem()
"
"mainMenu1
"
Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuEdit, Me.mnuOptions, Me.mnuRadioOptions, Me.mnuWindow, Me.mnuMenu1, Me.mnuMenu2})
"
"mnuFile
"
Me.mnuFile.Index = 0
Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNew, Me.mnuFileOpen, Me.mnuFileClose, Me.mnuFileSave, Me.mnuFileSaveAs})
Me.mnuFile.Text = "File"
"
"mnuNew
"
Me.mnuNew.Index = 0
Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.mnuNew.Text = "&New"
"
"mnuFileOpen
"
Me.mnuFileOpen.Index = 1
Me.mnuFileOpen.Text = "Open"
"
"mnuFileClose
"
Me.mnuFileClose.Index = 2
Me.mnuFileClose.Text = "Close"
"
"mnuFileSave
"
Me.mnuFileSave.Index = 3
Me.mnuFileSave.Text = "Save"
"
"mnuFileSaveAs
"
Me.mnuFileSaveAs.Index = 4
Me.mnuFileSaveAs.Text = "Save&As"
"
"mnuEdit
"
Me.mnuEdit.Index = 1
Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCopy, Me.mnuEditPaste})
Me.mnuEdit.Text = "Edit"
"
"mnuEditCopy
"
Me.mnuEditCopy.Index = 0
Me.mnuEditCopy.Text = "&Copy"
"
"mnuEditPaste
"
Me.mnuEditPaste.Index = 1
Me.mnuEditPaste.Text = "Paste"
"
"mnuOptions
"
Me.mnuOptions.Index = 2
Me.mnuOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOption1, Me.mnuOption2, Me.mnuOption3})
Me.mnuOptions.Text = "Options"
"
"mnuOption1
"
Me.mnuOption1.Index = 0
Me.mnuOption1.Text = "Option1"
"
"mnuOption2
"
Me.mnuOption2.Index = 1
Me.mnuOption2.Text = "Option2"
"
"mnuOption3
"
Me.mnuOption3.Index = 2
Me.mnuOption3.Text = "Option3"
"
"mnuRadioOptions
"
Me.mnuRadioOptions.Index = 3
Me.mnuRadioOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuRadioOption1, Me.mnuRadioOption2, Me.mnuRadioOption3})
Me.mnuRadioOptions.Text = "Radio Options"
"
"mnuROption1
"
Me.mnuRadioOption1.Index = 0
Me.mnuRadioOption1.RadioCheck = True
Me.mnuRadioOption1.Text = "Radio Option 1"
"
"mnuROption2
"
Me.mnuRadioOption2.Index = 1
Me.mnuRadioOption2.RadioCheck = True
Me.mnuRadioOption2.Text = "Radio Option 2"
"
"mnuROption3
"
Me.mnuRadioOption3.Index = 2
Me.mnuRadioOption3.RadioCheck = True
Me.mnuRadioOption3.Text = "Radio Option 3"
"
"mnuWindow
"
Me.mnuWindow.Index = 4
Me.mnuWindow.MdiList = True
Me.mnuWindow.MergeOrder = 99
Me.mnuWindow.Text = "&Window"
"
"mnuMenu1
"
Me.mnuMenu1.Index = 5
Me.mnuMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu11, Me.mnuMenu12, Me.mnuMenu13, Me.mnuMenu14, Me.mnuMerge})
Me.mnuMenu1.Text = "Menu 1"
"
"mnuMenu11
"
Me.mnuMenu11.Index = 0
Me.mnuMenu11.MergeOrder = 1
Me.mnuMenu11.Text = "Menu 1.1"
"
"mnuMenu12
"
Me.mnuMenu12.Index = 1
Me.mnuMenu12.MergeOrder = 2
Me.mnuMenu12.Text = "Menu 1.2"
"
"mnuMenu13
"
Me.mnuMenu13.Index = 2
Me.mnuMenu13.MergeOrder = 3
Me.mnuMenu13.Text = "Menu 1.3"
"
"mnuMenu14
"
Me.mnuMenu14.Index = 3
Me.mnuMenu14.MergeOrder = 4
Me.mnuMenu14.Text = "Menu 1.4"
"
"mnuMerge
"
Me.mnuMerge.Index = 4
Me.mnuMerge.MergeOrder = 99
Me.mnuMerge.Text = "Merge!"
"
"mnuMenu2
"
Me.mnuMenu2.Index = 6
Me.mnuMenu2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu21, Me.mnuMenu22, Me.mnuMenu23, Me.mnuMenu24})
Me.mnuMenu2.Text = "Menu 2"
"
"mnuMenu21
"
Me.mnuMenu21.Index = 0
Me.mnuMenu21.MergeOrder = 1
Me.mnuMenu21.Text = "Menu 2.1"
"
"mnuMenu22
"
Me.mnuMenu22.Index = 1
Me.mnuMenu22.MergeOrder = 2
Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace
Me.mnuMenu22.Text = "Menu 2.2"
"
"mnuMenu23
"
Me.mnuMenu23.Index = 2
Me.mnuMenu23.MergeOrder = 3
Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove
Me.mnuMenu23.Text = "Menu 2.3"
"
"mnuMenu24
"
Me.mnuMenu24.Index = 3
Me.mnuMenu24.MergeOrder = 5
Me.mnuMenu24.Text = "Menu 2.4"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(456, 146)
Me.IsMdiContainer = True
Me.Menu = Me.mainMenu1
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Private Sub mnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuNew.Click
Dim newMDIChild As New MDIChild()
newMDIChild.MdiParent = Me
newMDIChild.Show()
End Sub
Private Sub mnuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuFileOpen.Click
MessageBox.Show("You clicked file open!", _
"Menu event tester", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub
Private Sub mnuFileClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuFileClose.Click
MessageBox.Show("You clicked file close!", "Menu event tester", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub mnuEditCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuEditCopy.Click
MessageBox.Show("You clicked Edit copy!", "Menu event tester", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub mnuEditPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuEditPaste.Click
MessageBox.Show("You clicked Edit paste!", "Menu event tester", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuOption1.Click, mnuOption2.Click, mnuOption3.Click
Dim item As MenuItem = CType(sender, MenuItem)
item.Checked = Not item.Checked
End Sub
Private Sub RadioOption_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles mnuRadioOption1.Click, mnuRadioOption2.Click, mnuRadioOption3.Click
Dim item As MenuItem = CType(sender, MenuItem)
Dim parent As Menu = item.Parent
Dim tempMi As MenuItem
For Each tempMi In parent.MenuItems
tempMi.Checked = False
Next
item.Checked = True
End Sub
Private Sub mnuMerge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim item As MenuItem = CType(sender, MenuItem)
item.Parent.MergeMenu(mnuMenu2)
End Sub
End Class