Dev控件使用CheckedListBoxControl获取items.count为0 的解决方法
生活随笔
收集整理的這篇文章主要介紹了
Dev控件使用CheckedListBoxControl获取items.count为0 的解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
CheckedListBoxControl,我使用DataSource屬性,給其綁定了一個List對象。界面顯示都挺正常的,當若干個項的復選框被選中的后,它的checkedListBoxControl1.CheckedItems也是正常的。
唯獨的問題是在代碼中得到的checkedListBoxControl1.Items.Count 為0,自然就不能遍歷控件的中的所有項。checkedListBoxControl1能夠正確獲得某個Item對象的方法就剩下GetItemValue(idx)、SetItemChecked等。
如果你也遇到這種情況,請使用下面的方法來遍歷所有的Item,并做出相應的處理:
全不選:
public void ClearCheckState(){int idx = 0;while (checkedListBoxControl1.GetItemValue(idx) != null) { checkedListBoxControl1.SetItemChecked(idx, false); idx++; } }轉載于:https://www.cnblogs.com/ogre-zl/p/11533616.html
總結
以上是生活随笔為你收集整理的Dev控件使用CheckedListBoxControl获取items.count为0 的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到葱长的非常好是什么意思
- 下一篇: python:使用Djangorestf