WinForm–CheckedListBox数据绑定虽然点的时候没有提示 但是 CheckedListB 也是支持像 ComboBox 一样的数据绑定的 nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp cblBtn DataSource dt nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp cblBtn DisplayMembe AAA nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp cblBtn ValueMember BBB 不过在取这些值的时候稍有不同 不能直接通过 Item
虽然点的时候没有提示,但是CheckedListBox也是支持像ComboBox一样的数据绑定的
不过在取这些值的时候稍有不同,不能直接通过Items[i].Value来取值
而要
((DataRowView)this.cblBtn.Items[i]).Row["BBB"].ToString()
另外设置勾选时,通过方法 cblBtn.SetItemChecked(i, true) 设置
还有一点,CheckedListBox有个CheckedItems,里面存有所有选中项,如果只操作选中项的话就用它好了,不用挨个遍历了!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/209619.html原文链接:https://javaforall.net