06 May 2014

VB.NET: CheckBox Control Sample Project

Design UI:

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, _
        ByVal e
As System.EventArgs) Handles MyBase.Load
        CheckBox1.Text = "Use &Mnemonic"
        CheckBox1.Checked = True

        CheckBox2.Text = "Three State"
        CheckBox2.ThreeState = True

        CheckBox3.Text = "Use Wait Cursor"
        CheckBox4.Text = "Red Color"
        CheckBox5.Text = "Right Check"
    End Sub

    Private Sub CheckBox1_Click(ByVal sender As Object, _
        ByVal e
As System.EventArgs) Handles CheckBox1.Click
        CheckBox1.UseMnemonic = CheckBox1.Checked
    End Sub

    Private Sub CheckBox3_Click(ByVal sender
As Object, _
        ByVal e
As System.EventArgs) Handles CheckBox3.Click
        CheckBox3.UseWaitCursor = CheckBox3.Checked
    End Sub

    Private Sub CheckBox4_Click(ByVal sender
As Object, _
        ByVal e
As System.EventArgs) Handles CheckBox4.Click
        CheckBox4.ForeColor = IIf(CheckBox4.Checked = True, _
                                  Color.Red, Color.Black)
    End Sub

    Private Sub CheckBox5_Click(ByVal sender
As Object, _
        ByVal e
As System.EventArgs) Handles CheckBox5.Click
        CheckBox5.CheckAlign = IIf(CheckBox5.Checked = True, _
                                   ContentAlignment.MiddleRight, _
                                   ContentAlignment.MiddleLeft)
    End Sub

End Class


Runtime:


*Notes: untuk menampilkan Mnemonic, tekan Alt.
             (to display Mnemonic, push Alt)

Click here if you like this article.


Artikel Terkait:
CheckBox Events
CheckBox Properties
Checkbox Control
Common Control Visual Basic.NET
Tutorial Visual Basic .NET

0 comments: