本文整理汇总了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() + ".");
}
}