VB.NET - checkedlistbox

Asked By sinduja arunkumar on 16-Nov-10 04:10 AM
hi
can anyone pls tell me how to use the checkedlistboxcontrol.i have a checkedlistbox control in my form i just want to know how to insert items from checkedlistbox control to listview.if i select more than one record that selected items shoul be added into the listview .Its very urgent pls help me......
Reena Jain replied to sinduja arunkumar on 16-Nov-10 04:17 AM
hi
here is code for you
foreach (ListItem lstItem in checklistbox1.Items)
{
  if (lstItem.Selected)
    listbox1.Items.Add(lstItem.Text);
   
}
hope this will help you
Reena Jain replied to sinduja arunkumar on 16-Nov-10 04:18 AM
hi,

you can use a particular event like this

private void checkedList_ItemCheck(object sender, System.http://www.geekpedia.com/tutorial40_ListBox-and-CheckedListBox.html#.Forms.ItemCheckEventArgs e)
{
  if( e.NewValue == CheckState.Checked)
  {
  selectedList.Items.Add(checkedList.SelectedItem.ToString());
  }
  else
  {
  selectedList.Items.Remove(checkedList.SelectedItem.ToString());
  }
}


hope this will help you
sinduja arunkumar replied to Reena Jain on 16-Nov-10 06:12 AM
hi
sorry both codes r not working