CheckedListBox.ObjectCollection クラス

定義

CheckedListBox 内の項目のコレクションを表します。

public: ref class CheckedListBox::ObjectCollection : System::Windows::Forms::ListBox::ObjectCollection
public class CheckedListBox.ObjectCollection : System.Windows.Forms.ListBox.ObjectCollection
type CheckedListBox.ObjectCollection = class
    inherit ListBox.ObjectCollection
Public Class CheckedListBox.ObjectCollection
Inherits ListBox.ObjectCollection
継承
CheckedListBox.ObjectCollection

次の例では、 内の項目を列挙し、リスト内 CheckedListBox の他のすべての項目をチェックします。 この例では、 プロパティを Items 使用して、 を取得 CheckedListBox.ObjectCollection して項目の を取得する方法を Count 示します。

この例では、 メソッドと SetItemChecked メソッドをSetItemCheckState使用して項目のチェック状態を設定する方法も示しています。 チェック対象のその他のすべての項目について、 SetItemCheckState が 呼び出されて にIndeterminate設定CheckStateされます。一方SetItemChecked、他の項目では が呼び出され、チェック状態が にChecked設定されます。

void CheckEveryOther_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   
   // Cycle through every item and check every other.
   // Set flag to true to know when this code is being executed. Used in the ItemCheck
   // event handler.
   insideCheckEveryOther = true;
   for ( int i = 0; i < checkedListBox1->Items->Count; i++ )
   {
      
      // For every other item in the list, set as checked.
      if ( (i % 2) == 0 )
      {
         
         // But for each other item that is to be checked, set as being in an
         // indeterminate checked state.
         if ( (i % 4) == 0 )
                     checkedListBox1->SetItemCheckState( i, CheckState::Indeterminate );
         else
                     checkedListBox1->SetItemChecked( i, true );
      }

   }
   insideCheckEveryOther = false;
}
private void CheckEveryOther_Click(object sender, System.EventArgs e) {
    // Cycle through every item and check every other.

    // Set flag to true to know when this code is being executed. Used in the ItemCheck
    // event handler.
    insideCheckEveryOther = true;

    for (int i = 0; i < checkedListBox1.Items.Count; i++) {
        // For every other item in the list, set as checked.
        if ((i % 2) == 0) {
            // But for each other item that is to be checked, set as being in an
            // indeterminate checked state.
            if ((i % 4) == 0)
                checkedListBox1.SetItemCheckState(i, CheckState.Indeterminate);
            else
                checkedListBox1.SetItemChecked(i, true);
        }
    }

    insideCheckEveryOther = false;
}
Private Sub CheckEveryOther_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckEveryOther.Click
    ' Cycle through every item and check every other.
    Dim i As Integer

    ' Set flag to true to know when this code is being executed. Used in the ItemCheck
    ' event handler.
    insideCheckEveryOther = True

    For i = 0 To CheckedListBox1.Items.Count - 1
        ' For every other item in the list, set as checked.

        If ((i Mod 2) = 0) Then
            ' But for each other item that is to be checked, set as being in an
            ' indeterminate checked state.

            If ((i Mod 4) = 0) Then
                CheckedListBox1.SetItemCheckState(i, CheckState.Indeterminate)
            Else
                CheckedListBox1.SetItemChecked(i, True)
            End If
        End If
    Next

    insideCheckEveryOther = False

End Sub

注釈

コレクションは、 プロパティによってItems親コントロール CheckedListBoxからアクセスされます。 コントロールに表示CheckedListBoxするオブジェクトのコレクションを作成するには、 メソッドと Remove メソッドを使用Addして項目を個別に追加または削除します。

コンストラクター

CheckedListBox.ObjectCollection(CheckedListBox)

CheckedListBox.ObjectCollection クラスの新しいインスタンスを初期化します。

プロパティ

Count

コレクション内の項目の数を取得します。

(継承元 ListBox.ObjectCollection)
IsReadOnly

コレクションが読み取り専用かどうかを示す値を取得します。

(継承元 ListBox.ObjectCollection)
Item[Int32]

コレクション内の指定したインデックスにある項目を取得または設定します。

(継承元 ListBox.ObjectCollection)

メソッド

Add(Object)

ListBox の項目のリストに項目を追加します。

(継承元 ListBox.ObjectCollection)
Add(Object, Boolean)

追加するオブジェクトとそのオブジェクトがチェックされているかどうかを指定して、CheckedListBox の項目のリストに項目を追加します。

Add(Object, CheckState)

追加するオブジェクトとチェックされた値の初期状態を指定し、CheckedListBox のリストに項目を追加します。

AddRange(ListBox+ObjectCollection)

既存の ListBox.ObjectCollection の項目を ListBox の項目のリストに追加します。

(継承元 ListBox.ObjectCollection)
AddRange(Object[])

ListBox の項目のリストに、項目の配列を追加します。

(継承元 ListBox.ObjectCollection)
Clear()

コレクションからすべての項目を削除します。

(継承元 ListBox.ObjectCollection)
Contains(Object)

指定した項目がコレクション内にあるかどうかを確認します。

(継承元 ListBox.ObjectCollection)
CopyTo(Object[], Int32)

既存のオブジェクト配列内の指定した位置にコレクション全体をコピーします。

(継承元 ListBox.ObjectCollection)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetEnumerator()

項目コレクションを反復処理するために使用する列挙子を返します。

(継承元 ListBox.ObjectCollection)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IndexOf(Object)

指定した項目のコレクション内のインデックスを返します。

(継承元 ListBox.ObjectCollection)
Insert(Int32, Object)

リスト ボックス内の指定したインデックスに項目を挿入します。

(継承元 ListBox.ObjectCollection)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
Remove(Object)

指定したオブジェクトをコレクションから削除します。

(継承元 ListBox.ObjectCollection)
RemoveAt(Int32)

コレクション内の指定されたインデックスにある項目を削除します。

(継承元 ListBox.ObjectCollection)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

ICollection.CopyTo(Array, Int32)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

特定の配列インデックスを開始位置として、配列にコレクションの要素をコピーします。

(継承元 ListBox.ObjectCollection)
ICollection.IsSynchronized

このメンバーの詳細については、「IsSynchronized」をご覧ください。

(継承元 ListBox.ObjectCollection)
ICollection.SyncRoot

このメンバーの詳細については、「SyncRoot」をご覧ください。

(継承元 ListBox.ObjectCollection)
IList.Add(Object)

この API は製品インフラストラクチャをサポートします。コードから直接使用するものではありません。

オブジェクトを ListBox クラスに追加します。

(継承元 ListBox.ObjectCollection)
IList.Contains(Object)

IList に特定の値が格納されているかどうかを判断します。

(継承元 ListBox.ObjectCollection)
IList.IndexOf(Object)

IList 内の特定の項目のインデックスを確認します。

(継承元 ListBox.ObjectCollection)
IList.Insert(Int32, Object)

指定したインデックスの IList に項目を挿入します。

(継承元 ListBox.ObjectCollection)
IList.IsFixedSize

このメンバーの詳細については、「IsFixedSize」をご覧ください。

(継承元 ListBox.ObjectCollection)
IList.Item[Int32]

指定したインデックスにある要素を取得または設定します。

(継承元 ListBox.ObjectCollection)
IList.Remove(Object)

特定のオブジェクトが IList 内にあるときに、最初に出現したものを削除します。

(継承元 ListBox.ObjectCollection)

拡張メソッド

Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。

適用対象