views:

51

answers:

2

I am getting checkedListBox values from database. Based on my checkbox selection it will perform some operation.where i have to write the code for checked items.

+4  A: 

You need to subscribe to the CheckListBox.ItemCheck event. You can do this in code in your constructor or override to OnLoad or you can use the WinForms designer properties window events tab.

In code (where checkListBox is the name of your CheckListBox):

public MyType()
{
    this.checkListBox.ItemCheck += new ItemCheckEventHandler(OnCheckListBoxItemCheck);
}

private void OnCheckListBoxItemCheck(object sender, ItemCheckEventArgs args)
{
   //TODO: Do your operation...
}

In the designer:

  1. Select your CheckListBox in the designer
  2. Press Ctrl+F4 to view the Properties
  3. Select the Events tab (indicated by a little lightning bolt)
  4. Find the ItemCheck event and double-click - the event handler will be auto-generated and hooked up for you, you just need to add your code to make it do something
Jeff Yates
+1  A: 

Select the CheckedListBox in the designer, go to the Events tab in the Properties window, and double-click on any event.

SLaks
if i have 3 item in the check box.based on the item i will do some operation so how can i check it value.because it will bind the data at run time.and the run time data changed every time
Ayyappan.Anbalagan