menucontrolclient.vb
来自「Samples are organized by chapter, and th」· VB 代码 · 共 97 行
VB
97 行
Imports System.Drawing.Text
Public Class MenuControlClient
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.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.
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
Friend WithEvents imgMenu As System.Windows.Forms.ImageList
Friend WithEvents mnuFonts As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(MenuControlClient))
Me.MainMenu1 = New System.Windows.Forms.MainMenu()
Me.mnuFile = New System.Windows.Forms.MenuItem()
Me.imgMenu = New System.Windows.Forms.ImageList(Me.components)
Me.mnuFonts = New System.Windows.Forms.MenuItem()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile})
'
'mnuFile
'
Me.mnuFile.Index = 0
Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFonts})
Me.mnuFile.Text = "File"
'
'imgMenu
'
Me.imgMenu.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
Me.imgMenu.ImageSize = New System.Drawing.Size(16, 16)
Me.imgMenu.ImageStream = CType(resources.GetObject("imgMenu.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.imgMenu.TransparentColor = System.Drawing.Color.Transparent
'
'mnuFonts
'
Me.mnuFonts.Index = 0
Me.mnuFonts.Text = "Fonts"
'
'MenuControlClient
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Menu = Me.MainMenu1
Me.Name = "MenuControlClient"
Me.Text = "MenuControlClient"
End Sub
#End Region
Private Sub MenuControlClient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mnuFile.MenuItems.Add(New ImageMenuItem("New", imgMenu.Images(0)))
mnuFile.MenuItems.Add(New ImageMenuItem("Open", imgMenu.Images(1)))
mnuFile.MenuItems.Add(New ImageMenuItem("Save", imgMenu.Images(2)))
Dim Family As FontFamily, Fonts As New InstalledFontCollection()
For Each Family In Fonts.Families
Try
mnuFonts.MenuItems.Add(New ImageMenuItem(Family.Name, New Font(Family, 10), Nothing, Color.CornflowerBlue))
Catch
' Catch invalid fonts/styles and ignore them.
End Try
Next
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?