Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Getting Value from a checkedListBox on click using .Net 2.0

Author: Zunnair
Download Source Code : 812_controls.zip

In this simple article you will earn how to get value from a checkboxlist when one of its checkboxes is checked.

Create new c# project. Drag one checkboxlist control.

 
Now write following code in form load event.:
 
C#
private void Form1_Load(object sender, EventArgs e)
        {           
            checkedListBox1.Items.Add("CHK 1");
            checkedListBox1.Items.Add("CHK 2");
            checkedListBox1.Items.Add("CHK 3");
            checkedListBox1.Items.Add("CHK 4");
            checkedListBox1.Items.Add("CHK 5");
            checkedListBox1.Items.Add("CHK 6");
          
        }
 
VB
 
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
        checkedListBox1.Items.Add("CHK 1")
        checkedListBox1.Items.Add("CHK 2")
        checkedListBox1.Items.Add("CHK 3")
        checkedListBox1.Items.Add("CHK 4")
        checkedListBox1.Items.Add("CHK 5")
        checkedListBox1.Items.Add("CHK 6")
 
    End Sub
 
Now write the following code in item checked event:
 
C#
 
private void checkedListBox1_ItemCheck(object sender, temCheckEventArgs e)
        {
MessageBox.Show("Value of Check Box " + checkedListBox1.Items[e.Index].ToString());
        }
 
VB
 
Private Sub checkedListBox1_ItemCheck(ByVal sender As Object, ByVal e As temCheckEventArgs)
        MessageBox.Show("Value of Check Box " & checkedListBox1.Items(e.Index).ToString())
    End Sub
 
This is all for this.

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Adding Strings in DomainUpDown control on run time using .net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net