选中的列表框项目插入 [英] checked list box item insertion
本文介绍了选中的列表框项目插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将多个选中的项目从清单框插入数据库?
并在运行时将checkedlistbox与数据库绑定..
请帮助我...
how i can insert multiple selected items from checkedlistbox to database ??
and bind checkedlistbox with database at runtime..
plz help me...
推荐答案
string str ="
string str=""
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
尝试进行绑定:
Try this for binding:
((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);
}
现在,您可以使用 CheckedListBox.Items属性 [
Now you can use CheckedListBox.Items Property[^] to retrieve the items from checklistbox.
--Amit
这篇关于选中的列表框项目插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文