Click here to Skip to main content
15,942,292 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how i can insert multiple selected items from checkedlistbox to database ??
and bind checkedlistbox with database at runtime..
plz help me...
Posted
Comments
_Amy 3-Sep-12 2:16am    
What have you tried yet?

string str=""
SQL
For d = 0 To CBLDiv.Items.Count - 1
                   If CBLDiv.Items(d).Selected = True Then
                str=str + ","                         
                 End If
               Next

You can make string separated by comma all selected values will be there
whenever you want to load you can split that string
 
Share this answer
 
Try this for binding:
C#
((ListBox)this.checkedListBox1).DataSource = MyDataTable;
((ListBox)this.checkedListBox1).DisplayMember = "Name";
((ListBox)this.checkedListBox1).ValueMember = "IsChecked";
//Check the checkboxes if the IsChecked indicator is true
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
    randomClass obj = (randomClass)checkedListBox1.Items[i];
    checkedListBox1.SetItemChecked(i, obj.IsChecked);
}

Now you can use CheckedListBox.Items Property[^] to retrieve the items from checklistbox.


--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900