如何从Checked ListBox获取值 [英] How to get the value from a Checked ListBox

查看:71
本文介绍了如何从Checked ListBox获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows窗体中,有一个Checked ListBox.
用户可以在其中选择任何列表框.
当用户单击提交"按钮将其填满后,我想更新数据库中由用户选择的那些列表框值.
我已经尝试过这种方法,但是无法更新日期数据库中的所有值.

In my windows form there is a Checked ListBox.
there are some choices where user can select any list box.
After filling it up when user click on submit button i want to update those listbox values in my DB which are selected by the User.
I have tried this way but can''t update all the values in the datebase.

List<string> activities = new List<string>();
            for (int i = 0; i < LikingList.Items.Count; i++)

            {

    }


我可以从这里获取所有listBox名称,但是如何更新数据库中的每个listbox值.
在我的数据库中,所有列表框字段如
印度,意大利语,中文设置为位数据类型.

有任何建议吗?


I can get all the listBox name from here but how do i update each listbox value in my database.
In my database all the list box fields like
Indian,Italian.Chinese set as bit data type.

Any suggestion?

推荐答案

尝试一下

Try This

foreach (String item in checkedListBox1.CheckedItems) 
{  // iterate through <strong class="highlight">checked</strong> items
}


触发插入查询

Fire the insert query

INSERT INTO TABLENAME (VALUE1) VALUES('" + Item + "')


这篇关于如何从Checked ListBox获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆