Edit Menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Heibert

    #1

    Edit Menu

    Can anyone tell me how to create a Edit menu
    I am new to VB .Net and this news group

    Thanks,

    Brian


  • Newbie Coder

    #2
    Re: Edit Menu

    Brian,

    This is a simple exanmple I created for you

    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.
    InitializeCompo nent()

    'Add any initialization after the InitializeCompo nent() 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.Disp ose()
    End If
    End If
    MyBase.Dispose( disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.Componen tModel.IContain er

    '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 MenuItem1 As System.Windows. Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows. Forms.MenuItem
    Friend WithEvents MenuItem3 As System.Windows. Forms.MenuItem
    Friend WithEvents MenuItem4 As System.Windows. Forms.MenuItem
    Friend WithEvents MenuItem5 As System.Windows. Forms.MenuItem
    Friend WithEvents TextBox1 As System.Windows. Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows. Forms.TextBox
    <System.Diagnos tics.DebuggerSt epThrough()Priv ate Sub
    InitializeCompo nent()
    Me.MainMenu1 = New System.Windows. Forms.MainMenu
    Me.MenuItem1 = New System.Windows. Forms.MenuItem
    Me.MenuItem2 = New System.Windows. Forms.MenuItem
    Me.MenuItem3 = New System.Windows. Forms.MenuItem
    Me.MenuItem4 = New System.Windows. Forms.MenuItem
    Me.MenuItem5 = New System.Windows. Forms.MenuItem
    Me.TextBox1 = New System.Windows. Forms.TextBox
    Me.TextBox2 = New System.Windows. Forms.TextBox
    Me.SuspendLayou t()
    '
    'MainMenu1
    '
    Me.MainMenu1.Me nuItems.AddRang e(New System.Windows. Forms.MenuItem( )
    {Me.MenuItem1, Me.MenuItem3})
    '
    'MenuItem1
    '
    Me.MenuItem1.In dex = 0
    Me.MenuItem1.Me nuItems.AddRang e(New System.Windows. Forms.MenuItem( )
    {Me.MenuItem2})
    Me.MenuItem1.Te xt = "File"
    '
    'MenuItem2
    '
    Me.MenuItem2.In dex = 0
    Me.MenuItem2.Te xt = "Exit"
    '
    'MenuItem3
    '
    Me.MenuItem3.In dex = 1
    Me.MenuItem3.Me nuItems.AddRang e(New System.Windows. Forms.MenuItem( )
    {Me.MenuItem4, Me.MenuItem5})
    Me.MenuItem3.Te xt = "Edit"
    '
    'MenuItem4
    '
    Me.MenuItem4.In dex = 0
    Me.MenuItem4.Te xt = "Copy"
    '
    'MenuItem5
    '
    Me.MenuItem5.In dex = 1
    Me.MenuItem5.Te xt = "Paste"
    '
    'TextBox1
    '
    Me.TextBox1.Loc ation = New System.Drawing. Point(16, 16)
    Me.TextBox1.Nam e = "TextBox1"
    Me.TextBox1.Siz e = New System.Drawing. Size(96, 20)
    Me.TextBox1.Tab Index = 0
    Me.TextBox1.Tex t = "Text to copy"
    '
    'TextBox2
    '
    Me.TextBox2.Loc ation = New System.Drawing. Point(128, 16)
    Me.TextBox2.Nam e = "TextBox2"
    Me.TextBox2.Tab Index = 1
    Me.TextBox2.Tex t = ""
    '
    'Form1
    '
    Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
    Me.ClientSize = New System.Drawing. Size(240, 57)
    Me.Controls.Add (Me.TextBox2)
    Me.Controls.Add (Me.TextBox1)
    Me.Menu = Me.MainMenu1
    Me.Name = "Form1"
    Me.StartPositio n =
    System.Windows. Forms.FormStart Position.Center Screen
    Me.Text = "Edit Example"
    Me.ResumeLayout (False)

    End Sub

    #End Region

    Private Sub MenuItem2_Click (ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MenuItem2.Click
    Application.Exi t()
    End Sub

    Private Sub MenuItem4_Click (ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MenuItem4.Click
    If TextBox1.Select edText <"" Then
    Clipboard.SetDa taObject(TextBo x1.SelectedText )
    End If
    End Sub

    Private Sub MenuItem5_Click (ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MenuItem5.Click
    Dim iData As IDataObject = Clipboard.GetDa taObject()
    If iData.GetDataPr esent(DataForma ts.Text) Then
    TextBox2.Text = CType(iData.Get Data(DataFormat s.Text), String)
    End If
    End Sub
    End Class

    I hope this helps,

    --
    Newbie Coder
    (It's just a name)


    "Brian Heibert" <heibert@verizo n.netwrote in message
    news:uU$enpTlHH A.5084@TK2MSFTN GP03.phx.gbl...
    Can anyone tell me how to create a Edit menu
    I am new to VB .Net and this news group
    >
    Thanks,
    >
    Brian
    >
    >

    Comment

    Working...