Button CodeSample - With ContextMenu
From Visual WebGui Wiki
| This article will have a few sections added to it soon, based on the following article type skeleton: NewCodeSampleTemplate |
Overview
This code sample shows a simple Button control with a ContextMenu
VB.NET code
Imports Gizmox.WebGui.Forms Public Class Form2 Friend WithEvents ContextMenu1 As Gizmox.WebGui.Forms.ContextMenu Friend WithEvents MenuItem1 As Gizmox.WebGui.Forms.MenuItem Friend WithEvents MenuItem2 As Gizmox.WebGui.Forms.MenuItem Friend WithEvents Button1 As Gizmox.WebGui.Forms.Button Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.ContextMenu1 = New Gizmox.WebGui.Forms.ContextMenu Me.MenuItem1 = New Gizmox.WebGui.Forms.MenuItem Me.MenuItem2 = New Gizmox.WebGui.Forms.MenuItem Me.MenuItem1.Index = 0 Me.MenuItem1.Text = "Do This" Me.MenuItem1.Tag = "This" Me.MenuItem2.Index = 1 Me.MenuItem2.Text = "Do That" Me.MenuItem2.Tag = "That" Me.ContextMenu1.MenuItems.AddRange(New Gizmox.WebGui.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2}) Me.Button1 = New Gizmox.WebGui.Forms.Button Me.Button1.Size = New System.Drawing.Point(100, 100) Me.Button1.Text = "Right Click Form Menu" Me.Button1.ContextMenu = Me.ContextMenu1 Me.Controls.Add(Me.Button1) End Sub Private Sub Button1_MenuClick(ByVal objSource As System.Object, _ ByVal objArgs As Gizmox.WebGui.Forms.MenuItemEventArgs) _ Handles Button1.MenuClick If objArgs.MenuItem.Tag = "This" Then MessageBox.Show("Performing this") Else MessageBox.Show("Performing that") End If End Sub End Class
C# Code
| This part of the article has not been completed yet. Please feel free to contribute and add contents to the Wiki |
