當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET CheckBox.ThreeState屬性代碼示例

本文整理匯總了VB.NET中System.Windows.Forms.CheckBox.ThreeState屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET CheckBox.ThreeState屬性的具體用法?VB.NET CheckBox.ThreeState怎麽用?VB.NET CheckBox.ThreeState使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Windows.Forms.CheckBox的用法示例。


在下文中一共展示了CheckBox.ThreeState屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: AdjustMyCheckBoxProperties

Private Sub AdjustMyCheckBoxProperties()

    ' Change the ThreeState and CheckAlign properties on every other click.
    If Not checkBox1.ThreeState Then
        checkBox1.ThreeState = True
        checkBox1.CheckAlign = ContentAlignment.MiddleRight
    Else
        checkBox1.ThreeState = False
        checkBox1.CheckAlign = ContentAlignment.MiddleLeft
    End If

    ' Concatenate the property values together on three lines.
    label1.Text = "ThreeState: " & checkBox1.ThreeState.ToString() & ControlChars.Cr & _
        "Checked: " & checkBox1.Checked.ToString() & ControlChars.Cr & _
        "CheckState: " & checkBox1.CheckState.ToString()

End Sub
開發者ID:VB.NET開發者,項目名稱:System.Windows.Forms,代碼行數:17,代碼來源:CheckBox.ThreeState

示例2: Module1

' 導入命名空間
Imports System.Windows.Forms

Module Module1

    Sub Main()
        Application.Run(New Form1)
    End Sub

End Module




Public Class Form1
    Inherits System.Windows.Forms.Form
    Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
    Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox
    Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox
    Friend WithEvents Label1 As System.Windows.Forms.Label

    Public Sub New()
        MyBase.New()

        Me.CheckBox1 = New System.Windows.Forms.CheckBox()
        Me.CheckBox2 = New System.Windows.Forms.CheckBox()
        Me.CheckBox3 = New System.Windows.Forms.CheckBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'CheckBox1
        '
        Me.CheckBox1.Location = New System.Drawing.Point(24, 32)
        Me.CheckBox1.Name = "CheckBox1"
        Me.CheckBox1.TabIndex = 0
        Me.CheckBox1.Text = "Item 1 "
        Me.CheckBox1.ThreeState = True
        '
        'CheckBox2
        '
        Me.CheckBox2.Location = New System.Drawing.Point(24, 72)
        Me.CheckBox2.Name = "CheckBox2"
        Me.CheckBox2.Size = New System.Drawing.Size(136, 24)
        Me.CheckBox2.TabIndex = 1
        Me.CheckBox2.Text = "Item 2 "
        Me.CheckBox2.ThreeState = True
        '
        'CheckBox3
        '
        Me.CheckBox3.Location = New System.Drawing.Point(24, 112)
        Me.CheckBox3.Name = "CheckBox3"
        Me.CheckBox3.Size = New System.Drawing.Size(144, 24)
        Me.CheckBox3.TabIndex = 2
        Me.CheckBox3.Text = "Item 3"
        Me.CheckBox3.ThreeState = True
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(32, 176)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(224, 56)
        Me.Label1.TabIndex = 3
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.CheckBox3, Me.CheckBox2, Me.CheckBox1})
        Me.Name = "Form1"
        Me.Text = "CheckBoxDemo"
        Me.ResumeLayout(False)

    End Sub

    Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click, CheckBox2.Click, CheckBox3.Click
        Label1.Text = "Choices: "
        If (CheckBox1.Checked) Then
            Label1.Text = Label1.Text & " " & CheckBox1.Text
        End If

        If (CheckBox1.CheckState = CheckState.Indeterminate) Then
            Label1.Text = Label1.Text & " " & CheckBox1.Text & " (I)"
        End If

        If (CheckBox2.Checked) Then
            Label1.Text = Label1.Text & " " & CheckBox2.Text
        End If

        If (CheckBox2.CheckState = CheckState.Indeterminate) Then
            Label1.Text = Label1.Text & " " & CheckBox2.Text & " (I)"
        End If

        If (CheckBox3.Checked) Then
            Label1.Text = Label1.Text & " " & CheckBox3.Text
        End If

        If (CheckBox3.CheckState = CheckState.Indeterminate) Then
            Label1.Text = Label1.Text & " " & CheckBox3.Text & " (I)"
        End If

        Label1.Refresh()
    End Sub

End Class
開發者ID:VB程序員,項目名稱:System.Windows.Forms,代碼行數:104,代碼來源:CheckBox.ThreeState


注:本文中的System.Windows.Forms.CheckBox.ThreeState屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。