The following example shows how to create checkedlistbox control at run time with event handling using c# programming language. it also demonstrate how to bind checklistbox control at run time with different methods.
using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; public class Form2 { CheckedListBox chkListBox; private void Form2_Load(System.Object sender, System.EventArgs e) { } private void CreateCheckedlistBox() { chkListBox = new CheckedListBox(); chkListBox.FormattingEnabled = true; chkListBox.Location = new System.Drawing.Point(12, 34); chkListBox.Name = "CheckedListBox1"; chkListBox.Size = new System.Drawing.Size(120, 94); chkListBox.CheckOnClick = true; chkListBox.ItemCheck += chkListBox_ItemCheck; this.Controls.Add(chkListBox); } private void chkListBox_ItemCheck(System.Object sender, System.Windows.Forms.ItemCheckEventArgs e) { MessageBox.Show(chkListBox.Items(e.Index).ToString); } private void BindCheckedlistBox() { chkListBox.Items.Add("Londan"); chkListBox.Items.Add("New Delhi"); chkListBox.Items.Add("NewYork"); } public Form2() { Load += Form2_Load; } //Private Sub BindCheckedlistBox() // Dim cities() As String = {"Londan", "New Delhi", "NewYork"} // chkListBox.Items.AddRange(cities) //End Sub }