本文整理匯總了C#中System.Windows.Forms.CheckedListBox.CheckedIndexCollection類的典型用法代碼示例。如果您正苦於以下問題:C# CheckedListBox.CheckedIndexCollection類的具體用法?C# CheckedListBox.CheckedIndexCollection怎麽用?C# CheckedListBox.CheckedIndexCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CheckedListBox.CheckedIndexCollection類屬於System.Windows.Forms命名空間,在下文中一共展示了CheckedListBox.CheckedIndexCollection類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WhatIsChecked_Click
private void WhatIsChecked_Click(object sender, System.EventArgs e) {
// Display in a message box all the items that are checked.
// First show the index and check state of all selected items.
foreach(int indexChecked in checkedListBox1.CheckedIndices) {
// The indexChecked variable contains the index of the item.
MessageBox.Show("Index#: " + indexChecked.ToString() + ", is checked. Checked state is:" +
checkedListBox1.GetItemCheckState(indexChecked).ToString() + ".");
}
// Next show the object title and check state for each item selected.
foreach(object itemChecked in checkedListBox1.CheckedItems) {
// Use the IndexOf method to get the index of an item.
MessageBox.Show("Item with title: \"" + itemChecked.ToString() +
"\", is checked. Checked state is: " +
checkedListBox1.GetItemCheckState(checkedListBox1.Items.IndexOf(itemChecked)).ToString() + ".");
}
}