Search KB Filter article types
CheckBox CodeSample - CheckBox with ContextMenu
Categories: Menus, Status & Indication
Tags: Developers, Navigation, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
Revision: 1
Posted: 20/Sep/2009
Updated: 23/July/2010
Status: Publish
Types: Code

This article will have a few sections added to it soon, based on the following article type skeleton: CodeSample
Overview

This is an example of a CheckBox with a ContextMenu attached to it, including an event handler to handle the MenuClick.

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 MenuItem3 As Gizmox.WebGui.Forms.MenuItem
    Friend WithEvents MenuItem4 As Gizmox.WebGui.Forms.MenuItem
    Friend WithEvents CheckBox1 As Gizmox.WebGui.Forms.CheckBox
    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.MenuItem3 = New Gizmox.WebGui.Forms.MenuItem
        Me.MenuItem4 = 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.MenuItem3.Index = 2
        Me.MenuItem3.Text = "I'm disabled"
        Me.MenuItem3.Tag = "Disabled"
        Me.MenuItem3.Enabled = False
 
        Me.MenuItem4.Index = 3
        Me.MenuItem4.Text = "Hide me"
        Me.MenuItem4.Tag = "Hide"
 
        Me.ContextMenu1.MenuItems.AddRange(New Gizmox.WebGui.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2, Me.MenuItem3, Me.MenuItem4})
 
        Me.CheckBox1 = New Gizmox.WebGui.Forms.CheckBox
        Me.CheckBox1.Size = New System.Drawing.Point(100, 100)
        Me.CheckBox1.Text = "Right Click For Menu"
        Me.CheckBox1.ContextMenu = Me.ContextMenu1
 
        Me.Controls.Add(Me.CheckBox1)
    End Sub
 
    Private Sub CheckBox1_MenuClick(ByVal objSource As System.Object, ByVal objArgs As Gizmox.WebGui.Forms.MenuItemEventArgs) Handles CheckBox1.MenuClick
        If objArgs.MenuItem.Tag = "This" Then
            MessageBox.Show("Performing this")
        ElseIf objArgs.MenuItem.Tag = "That" Then
            MessageBox.Show("Performing that")
        ElseIf objArgs.MenuItem.Tag = "Disabled" Then
            MessageBox.Show("This should not be possible... I'm disabled")
        Else
            Me.MenuItem4.Visible = False
            Me.ContextMenu1.Update()
        End If
    End Sub
 
End Class

C# Code
The conversion of this code to C# has not been completed yet.

About the author

Related Articles

Menus  
Title Update Author
This video demonstrates how to create and use a context menu in Visual WebGui.
Tags: Developers, 1. Beginner, Pre v6.3, v6.3, v6.4 and Later, 2. Intermediate, 3. Advanced
01/Jan/2009    2009/01/01
Tags: Developers, Navigation, 1. Beginner, 2. Intermediate, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
23/July/2010    2010/07/23
Tags: Architects, Developers, Navigation, 1. Beginner, 2. Intermediate, 3. Advanced, Navigation, Pre v6.3, v6.3, v6.4 and Later
04/Dec/2010    2010/12/04
Tags: Developers, Navigation, 1. Beginner, 2. Intermediate, Navigation, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
23/July/2010    2010/07/23
Tags: Architects, Developers, Navigation, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
04/Dec/2010    2010/12/04
Tags: Developers, 1. Beginner, 2. Intermediate, Customization, Pre v6.3, v6.3, v6.4 and Later, 3. Advanced
24/May/2010    2010/05/24
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS