Create Menu in your code : Menu « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » Menu 
14.17.1.Create Menu in your code
Create Menu in your code
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class MenuCreationInCode
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim mainMenu1 As New MainMenu

    Dim WithEvents menuItem1 As New MenuItem
    Dim WithEvents menuItem2 As New MenuItem
    Dim WithEvents menuItem3 As New MenuItem
    Dim WithEvents menuItem4 As New MenuItem


    Public Sub New()
        MyBase.New()

        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(292273)

        menuItem1.Text = "File"
        menuItem2.Text = "Item 1"
        menuItem3.Text = "Item 2"
        menuItem3.Checked = True
        menuItem4.Text = "Exit"
        menuItem4.Shortcut = Shortcut.CtrlX
        menuItem2.MenuItems.Add(menuItem3)
        menuItem1.MenuItems.Add(menuItem2)
        menuItem1.MenuItems.Add(menuItem4)
        AddHandler menuItem4.Click, AddressOf MenuItem4_Click
        mainMenu1.MenuItems.Add(menuItem1)
        Menu = mainMenu1
    End Sub

    Private Sub MenuItem4_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs)
        
        Console.WriteLine("action")
    End Sub

End Class
14.17.Menu
14.17.1.Create Menu in your codeCreate Menu in your code
14.17.2.Add Menu to Form window and attach actionsAdd Menu to Form window and attach actions
14.17.3.Build menu at runtimeBuild menu at runtime
14.17.4.Using menus to change font colors and stylesUsing menus to change font colors and styles
14.17.5.Owner draw menuOwner draw menu
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.