本文整理汇总了VB.NET中System.Windows.Forms.MenuItem.Checked属性的典型用法代码示例。如果您正苦于以下问题:VB.NET MenuItem.Checked属性的具体用法?VB.NET MenuItem.Checked怎么用?VB.NET MenuItem.Checked使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.MenuItem 的用法示例。
在下文中一共展示了MenuItem.Checked属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: MyMenuClick
' The following event handler would be connected to three menu items.
Private Sub MyMenuClick(sender As Object, e As EventArgs)
' Determine if clicked menu item is the Blue menu item.
If sender Is menuItemBlue Then
' Set the checkmark for the menuItemBlue menu item.
menuItemBlue.Checked = True
' Uncheck the menuItemRed and menuItemGreen menu items.
menuItemRed.Checked = False
menuItemGreen.Checked = False
' Set the color of the text in the TextBox control to Blue.
textBox1.ForeColor = Color.Blue
Else
If sender Is menuItemRed Then
' Set the checkmark for the menuItemRed menu item.
menuItemRed.Checked = True
' Uncheck the menuItemBlue and menuItemGreen menu items.
menuItemBlue.Checked = False
menuItemGreen.Checked = False
' Set the color of the text in the TextBox control to Red.
textBox1.ForeColor = Color.Red
Else
' Set the checkmark for the menuItemGreen.
menuItemGreen.Checked = True
' Uncheck the menuItemRed and menuItemBlue menu items.
menuItemBlue.Checked = False
menuItemRed.Checked = False
' Set the color of the text in the TextBox control to Blue.
textBox1.ForeColor = Color.Green
End If
End If
End Sub
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:31,代码来源:MenuItem.Checked
示例2: DynamicMenu
' 导入命名空间
Imports System.Windows.Forms
public class DynamicMenu
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
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
Private components As System.ComponentModel.IContainer
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 MenuItem6 As System.Windows.Forms.MenuItem
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
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.MenuItem6 = New System.Windows.Forms.MenuItem
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem3})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2})
Me.MenuItem1.Text = "File"
'
'MenuItem2
'
Me.MenuItem2.Index = 0
Me.MenuItem2.Text = "Open"
'
'MenuItem3
'
Me.MenuItem3.Index = 1
Me.MenuItem3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem4, Me.MenuItem5, Me.MenuItem6})
Me.MenuItem3.Text = "Edit"
'
'MenuItem4
'
Me.MenuItem4.Index = 0
Me.MenuItem4.Text = "Cut"
'
'MenuItem5
'
Me.MenuItem5.Index = 1
Me.MenuItem5.Text = "Copy"
'
'MenuItem6
'
Me.MenuItem6.Index = 2
Me.MenuItem6.Text = "Paste"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(200, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(72, 24)
Me.Button1.TabIndex = 3
Me.Button1.Text = "Select"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(200, 48)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(72, 24)
Me.Button2.TabIndex = 4
Me.Button2.Text = "Disable"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(200, 88)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(72, 24)
Me.Button3.TabIndex = 5
Me.Button3.Text = "RadioButton"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(200, 136)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(72, 24)
Me.Button4.TabIndex = 6
Me.Button4.Text = "Hide"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 225)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Menu = Me.MainMenu1
Me.ResumeLayout(False)
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MenuItem4.RadioCheck = False
MenuItem5.RadioCheck = False
MenuItem6.RadioCheck = False
MenuItem6.Checked = MenuItem4.Checked
MenuItem4.Checked = Not MenuItem4.Checked
MenuItem5.Checked = Not MenuItem5.Checked
MenuItem6.Checked = Not MenuItem6.Checked
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MenuItem4.RadioCheck = False
MenuItem5.RadioCheck = False
MenuItem6.RadioCheck = False
MenuItem6.Checked = MenuItem4.Checked
MenuItem4.Enabled = Not MenuItem4.Enabled
MenuItem5.Enabled = Not MenuItem5.Enabled
MenuItem6.Enabled = Not MenuItem6.Enabled
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MenuItem4.Checked = False
MenuItem5.Checked = False
MenuItem6.Checked = True
MenuItem6.RadioCheck = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
MenuItem6.Visible = Not MenuItem6.Visible
End Sub
End Class
开发者ID:VB程序员,项目名称:System.Windows.Forms,代码行数:167,代码来源:MenuItem.Checked
注:本文中的System.Windows.Forms.MenuItem.Checked属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论