CheckedListBox.CheckedIndexCollection 클래스

정의

확인할 수 없는 상태의 항목을 포함하여 선택한 항목 인덱스의 컬렉션을 CheckedListBox에 캡슐화합니다.

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

예제

다음 예제에서는 열거에서 선택한 항목에는 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 1
1 3
2 4

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

이전 예제에 따라 매개 변수 값이 1인 속성에 대한 호출 Item[] 은 값 3을 반환합니다. 매개 변수가 3인 호출 IndexOf 은 값 1을 반환합니다.

속성

Count

선택한 항목의 개수를 가져옵니다.

IsReadOnly

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

Item[Int32]

CheckedListBox 컨트롤에서 선택한 항목의 인덱스를 가져옵니다.

메서드

Contains(Int32)

지정된 인덱스가 컬렉션에 위치하는지 여부를 확인합니다.

CopyTo(Array, Int32)

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

Equals(Object)

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

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

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

GetHashCode()

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

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

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

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

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

MemberwiseClone()

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

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

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

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.IsSynchronized

CheckedListBox.CheckedIndexCollection에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.

ICollection.SyncRoot

컨트롤 컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다. 이 멤버에 대한 설명은 SyncRoot를 참조하세요.

IList.Add(Object)

이 API는 제품 인프라를 지원하며 코드에서 직접 사용되지 않습니다.

CheckedListBox.CheckedIndexCollection에 항목을 추가합니다. 이 멤버에 대한 설명은 Add(Object)를 참조하세요.

IList.Clear()

CheckedListBox.CheckedIndexCollection에서 항목을 모두 제거합니다. 이 멤버에 대한 설명은 Clear()를 참조하세요.

IList.Contains(Object)

지정된 인덱스가 CheckedListBox.CheckedIndexCollection에 위치하는지 여부를 확인합니다. 이 멤버에 대한 설명은 Contains(Object)를 참조하세요.

IList.IndexOf(Object)

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

IList.Insert(Int32, Object)

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

IList.IsFixedSize

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

IList.Item[Int32]

이 멤버에 대한 설명은 Item[Int32]를 참조하세요.

IList.Remove(Object)

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

IList.RemoveAt(Int32)

이 멤버에 대한 설명은 RemoveAt(Int32)를 참조하십시오.

확장 메서드

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보