02 April 2014

VB.NET: CheckedListBox Control


CheckedListBox memiliki fasilitas seperti ListBox dengan tambahan checkbox untuk setiap item di listnya. User dapat mengubah centang pada checkbox-checkbox tersebut.


Contoh penggunaan CheckedListBox:
 UI:

Kita dapat menambahkan isi list item dengan menggunakan array.
 Private Sub Form2_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    Dim days As String() = {"Senin", "Selasa", "Rabu", _
                   "Kamis", "Jumat", "Sabtu", "Minggu"}
    CheckedListBox1.Items.AddRange(days)
    Button1.Text = "Reload"
 End Sub


Juga dapat menambahkannya satu per satu sekaligus menentukan status check per item.
 Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    CheckedListBox1.Items.Clear()
    CheckedListBox1.Items.Add("Senin", CheckState.Checked)
    CheckedListBox1.Items.Add("Selasa", CheckState.Unchecked)
    CheckedListBox1.Items.Add("Rabu", CheckState.Indeterminate)
    CheckedListBox1.Items.Add("Kamis", CheckState.Checked)
    CheckedListBox1.Items.Add("Jumat", CheckState.Unchecked)
    CheckedListBox1.Items.Add("Sabtu", CheckState.Indeterminate)
    CheckedListBox1.Items.Add("Minggu", CheckState.Indeterminate)
 End Sub




Click here if you like this article.


Artikel Terkait:
CheckedListBox Event
CheckedListBox Properties
Common Control Visual Basic .NET
Tutorial Visual Basic.NET

Contoh Project:
CheckedListBox Control Sample Project

1 comments:

rezar juventini said...
This comment has been removed by the author.