2012-09-27 52 views
3

我有一個CheckedListBox這樣的:CheckedListBox並與它們的索引檢查項目列表

:'''''''''''''''/\ 
: [ ] item1  || 
: [x] item2  || 
: [ ] item3  ## 
: [ ] item4  || 
: [x] item5  || 
L...............\/ 

現在我想提取檢查項目的索引:

int[] indexes = ExtractCheckedIndexes (myCheckedListBox); 

現在指標應該有2元= {1,4}。
如何做到這一點?

回答

11
int[] indexes = myCheckedListBox.CheckedIndices.Cast<int>().ToArray() 
+0

其實我是這樣訪問它們的:myCheckedListBox.CheckedIndices [0]。 – zgnilec

+0

我剛剛回答你的問題... – Patrik

+0

這就是爲什麼我給你+1。 – zgnilec

相關問題