CheckedListBox.CheckedItemCollection 클래스

정의

비활성화 상태의 항목을 포함하여 선택한 항목의 컬렉션을 CheckedListBox 컨트롤에 캡슐화합니다.

public: ref class CheckedListBox::CheckedItemCollection : System::Collections::IList
public class CheckedListBox.CheckedItemCollection : System.Collections.IList
type CheckedListBox.CheckedItemCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class CheckedListBox.CheckedItemCollection
Implements IList
상속
CheckedListBox.CheckedItemCollection
구현

예제

다음 예제에서는 열거에서 선택한 항목에는 CheckedListBox.CheckedIndexCollection 확인 하기 위해 어떤 상태 항목입니다. 예제를 사용 하 여는 GetItemCheckState 메서드 항목의 선택 상태를 설정 합니다. 또한 예제에 사용 하 여는 CheckedIndices 가져올 속성을 CheckedListBox.CheckedIndexCollection, 및 CheckedItems 가져올 속성을를 CheckedListBox.CheckedItemCollection.

첫 번째 루프를 사용 합니다 GetItemCheckState 메서드를는 CheckState 항목의 인덱스를 지정 합니다. 선택한 각 항목의 합니다. 두 번째 루프에서는 또한 GetItemCheckState, 하지만 사용 하 여는 ListBox.ObjectCollection.IndexOf 항목에 대 한 인덱스를 검색 하는 방법입니다.

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.
   IEnumerator^ myEnum1 = checkedListBox1->CheckedIndices->GetEnumerator();
   while ( myEnum1->MoveNext() )
   {
      Int32 indexChecked =  *safe_cast<Int32^>(myEnum1->Current);
      
      // The indexChecked variable contains the index of the item.
      MessageBox::Show( String::Concat( "Index#: ", indexChecked, ", is checked. Checked state is: ", checkedListBox1->GetItemCheckState( indexChecked ), "." ) );
   }

   
   // Next show the Object* title and check state for each item selected.
   IEnumerator^ myEnum2 = checkedListBox1->CheckedItems->GetEnumerator();
   while ( myEnum2->MoveNext() )
   {
      Object^ itemChecked = safe_cast<Object^>(myEnum2->Current);
      
      // Use the IndexOf method to get the index of an item.
      MessageBox::Show( String::Concat( "Item with title: \"", itemChecked, "\", is checked. Checked state is: ", checkedListBox1->GetItemCheckState( checkedListBox1->Items->IndexOf( itemChecked ) ), "." ) );
   }
}
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() + ".");
    }
}
Private Sub WhatIsChecked_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WhatIsChecked.Click
    ' Display in a message box all the items that are checked.
    Dim indexChecked As Integer
    Dim itemChecked As Object
    Const quote As String = """"

    ' First show the index and check state of all selected items.
    For Each 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

    ' Next show the object title and check state for each item selected.
    For Each itemChecked In CheckedListBox1.CheckedItems

        ' Use the IndexOf method to get the index of an item.
        MessageBox.Show("Item with title: " + quote + itemChecked.ToString() + quote + _
                        ", is checked. Checked state is: " + _
                        CheckedListBox1.GetItemCheckState(CheckedListBox1.Items.IndexOf(itemChecked)).ToString() + ".")
    Next

End Sub

설명

선택한 항목 컬렉션의 모든 항목의 하위 집합인는 CheckedListBox 컨트롤을 선택 또는 비활성화 된 상태에 있는 항목만 포함 합니다.

다음 표는 인덱싱된 컬렉션 컨트롤 (컨트롤에 포함 된 모든 항목)에 있는 항목의 예입니다.

인덱스 항목 상태 확인
0 개체 1 Unchecked
1 개체 2 Checked
2 개체 3 Unchecked
3 개체 4 Indeterminate
4 개체 5 Checked

이전 예제에 따라 다음 표에서 선택한 항목의 인덱싱된 컬렉션을 보여 줍니다.

인덱스 항목
0 개체 2
1 개체 4
2 개체 5

합니다 CheckedListBox 클래스에는 저장 된 인덱스에 액세스할 수 있도록 하는 두 명의 멤버를 Item[] 속성 및 IndexOf 메서드.

이전 예제에 대 한 호출에 따라는 Item[] 속성 매개 변수 값이 1 인 개체 4를 반환 합니다. 에 대 한 호출 IndexOf 4 개체의 매개 변수를 사용 하 여 1의 값을 반환 합니다.

속성

Count

컬렉션의 항목 수를 가져옵니다.

IsReadOnly

컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

Item[Int32]

선택한 항목 컬렉션의 개체를 가져옵니다.

메서드

Contains(Object)

지정된 항목이 컬렉션에 있는지 여부를 확인합니다.

CopyTo(Array, Int32)

배열 내의 지정된 위치에서 기존 배열로 전체 컬렉션을 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

CheckedItems 컬렉션 전체를 반복하는 데 사용할 수 있는 열거자를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(Object)

선택한 항목 컬렉션에 포함된 인덱스를 반환합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.IsSynchronized

이 멤버에 대한 설명은 IsSynchronized를 참조하세요.

ICollection.SyncRoot

이 멤버에 대한 설명은 SyncRoot를 참조하세요.

IList.Add(Object)

이 멤버에 대한 설명은 Add(Object)를 참조하세요.

IList.Clear()

이 멤버에 대한 설명은 Clear()를 참조하세요.

IList.Insert(Int32, Object)

이 멤버에 대한 설명은 Insert(Int32, Object)를 참조하세요.

IList.IsFixedSize

이 멤버에 대한 설명은 IsFixedSize를 참조하세요.

IList.Remove(Object)

이 멤버에 대한 설명은 Remove(Object)를 참조하세요.

IList.RemoveAt(Int32)

이 멤버에 대한 설명은 RemoveAt(Int32)를 참조하세요.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상