Imports System.Windows.Forms
public class ToolBarMenu
public Shared Sub Main
Application.Run(New Form1)
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.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 mnuEdit As System.Windows.Forms.MenuItem
Friend WithEvents mnuEditCut As System.Windows.Forms.MenuItem
Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem
Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem
Friend WithEvents txtEdit As System.Windows.Forms.TextBox
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents cmnuCut As System.Windows.Forms.MenuItem
Friend WithEvents cmnuCopy As System.Windows.Forms.MenuItem
Friend WithEvents cmnuPaste As System.Windows.Forms.MenuItem
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.MainMenu1 = New System.Windows.Forms.MainMenu()
Me.mnuEdit = New System.Windows.Forms.MenuItem()
Me.mnuEditCut = New System.Windows.Forms.MenuItem()
Me.mnuEditCopy = New System.Windows.Forms.MenuItem()
Me.mnuEditPaste = New System.Windows.Forms.MenuItem()
Me.txtEdit = New System.Windows.Forms.TextBox()
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu()
Me.cmnuCut = New System.Windows.Forms.MenuItem()
Me.cmnuCopy = New System.Windows.Forms.MenuItem()
Me.cmnuPaste = New System.Windows.Forms.MenuItem()
Me.MenuItem7 = New System.Windows.Forms.MenuItem()
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton()
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton()
Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton()
Me.ToolBar1 = New System.Windows.Forms.ToolBar()
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEdit})
'
'mnuEdit
'
Me.mnuEdit.Index = 0
Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCut, Me.mnuEditCopy, Me.mnuEditPaste})
Me.mnuEdit.Text = "&Edit"
'
'mnuEditCut
'
Me.mnuEditCut.Index = 0
Me.mnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX
Me.mnuEditCut.Text = "Cu&t"
'
'mnuEditCopy
'
Me.mnuEditCopy.Index = 1
Me.mnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC
Me.mnuEditCopy.Text = "&Copy"
'
'mnuEditPaste
'
Me.mnuEditPaste.Index = 2
Me.mnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV
Me.mnuEditPaste.Text = "&Paste"
'
'txtEdit
'
Me.txtEdit.ContextMenu = Me.ContextMenu1
Me.txtEdit.Location = New System.Drawing.Point(0, 24)
Me.txtEdit.Multiline = True
Me.txtEdit.Name = "txtEdit"
Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtEdit.Size = New System.Drawing.Size(248, 176)
Me.txtEdit.TabIndex = 0
Me.txtEdit.Text = ""
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.cmnuCut, Me.cmnuCopy, Me.cmnuPaste})
'
'cmnuCut
'
Me.cmnuCut.Index = 0
Me.cmnuCut.Text = "Cut"
'
'cmnuCopy
'
Me.cmnuCopy.Index = 1
Me.cmnuCopy.Text = "Copy"
'
'cmnuPaste
'
Me.cmnuPaste.Index = 2
Me.cmnuPaste.Text = "Paste"
'
'MenuItem7
'
Me.MenuItem7.Index = -1
Me.MenuItem7.Text = ""
'
'ToolBarButton1
'
Me.ToolBarButton1.ImageIndex = 0
'
'ToolBarButton2
'
Me.ToolBarButton2.ImageIndex = 1
'
'ToolBarButton3
'
Me.ToolBarButton3.ImageIndex = 2
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3})
Me.ToolBar1.ButtonSize = New System.Drawing.Size(23, 22)
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(248, 25)
Me.ToolBar1.TabIndex = 1
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(248, 201)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ToolBar1, Me.txtEdit})
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
mnuEditCut_Click(sender, e)
Case 1
mnuEditCopy_Click(sender, e)
Case 2
mnuEditPaste_Click(sender, e)
End Select
End Sub
Private Sub mnuEditCut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEditCut.Click, cmnuCut.Click
txtEdit.Cut()
End Sub
Private Sub mnuEditCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEditCopy.Click, cmnuCopy.Click
txtEdit.Copy()
End Sub
Private Sub mnuEditPaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuEditPaste.Click, cmnuPaste.Click
txtEdit.Paste()
End Sub
End Class
|