1
Public Class Form1
2
Inherits System.Windows.Forms.Form
3
4
Windows 窗体设计器生成的代码
66
67
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
68
CreateMyMainMenu1()
69
End Sub
70
71
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
72
73
74
CreateMyMainMenu1()
75
End Sub
76
77
Public Sub CreateMyMainMenu1()
78
' Create an empty MainMenu.
79
Dim mainMenu1 As New MainMenu
80
81
Dim menuItem1 As New MenuItem
82
Dim menuItem2 As New MenuItem
83
84
menuItem1.Text = "File"
85
menuItem2.Text = "Edit"
86
' Add two MenuItem objects to the MainMenu.
87
mainMenu1.MenuItems.Add(menuItem1)
88
mainMenu1.MenuItems.Add(menuItem2)
89
90
' 绑定窗体
91
Menu = mainMenu1
92
End Sub
93
94
Public Sub CreateMyMainMenu2()
95
' Create an empty MainMenu.
96
Dim mainMenu2 As New MainMenu
97
98
Dim menuItem1 As New MenuItem
99
Dim menuItem2 As New MenuItem
100
101
menuItem1.Text = "File2"
102
menuItem2.Text = "Edit2"
103
' Add two MenuItem objects to the MainMenu.
104
mainMenu2.MenuItems.Add(menuItem1)
105
mainMenu2.MenuItems.Add(menuItem2)
106
107
' 绑定窗体
108
Menu = mainMenu2
109
End Sub
110
111
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
112
CreateMyMainMenu2()
113
End Sub
114
End Class
115
116
Public Class Form12
Inherits System.Windows.Forms.Form3

4
Windows 窗体设计器生成的代码66

67
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load68
CreateMyMainMenu1()69
End Sub70

71
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click72
73
74
CreateMyMainMenu1()75
End Sub76

77
Public Sub CreateMyMainMenu1()78
' Create an empty MainMenu.79
Dim mainMenu1 As New MainMenu80

81
Dim menuItem1 As New MenuItem82
Dim menuItem2 As New MenuItem83

84
menuItem1.Text = "File"85
menuItem2.Text = "Edit"86
' Add two MenuItem objects to the MainMenu.87
mainMenu1.MenuItems.Add(menuItem1)88
mainMenu1.MenuItems.Add(menuItem2)89

90
' 绑定窗体91
Menu = mainMenu192
End Sub93

94
Public Sub CreateMyMainMenu2()95
' Create an empty MainMenu.96
Dim mainMenu2 As New MainMenu97

98
Dim menuItem1 As New MenuItem99
Dim menuItem2 As New MenuItem100

101
menuItem1.Text = "File2"102
menuItem2.Text = "Edit2"103
' Add two MenuItem objects to the MainMenu.104
mainMenu2.MenuItems.Add(menuItem1)105
mainMenu2.MenuItems.Add(menuItem2)106

107
' 绑定窗体108
Menu = mainMenu2109
End Sub110

111
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click112
CreateMyMainMenu2()113
End Sub114
End Class115

116


浙公网安备 33010602011771号