CheckedListBox.ObjectCollection クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CheckedListBox.ObjectCollection クラスの意味・解説 

CheckedListBox.ObjectCollection クラス

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

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class ObjectCollection
    Inherits ObjectCollection
Dim instance As ObjectCollection
public class ObjectCollection : ObjectCollection
public ref class ObjectCollection : public
 ObjectCollection
public class ObjectCollection extends ObjectCollection
public class ObjectCollection extends
 ObjectCollection
解説解説
使用例使用例

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

この例では、SetItemCheckState メソッドおよび SetItemChecked メソッド使用して、項目のチェック状態を設定してます。チェックする項目は 1 つおきに、SetItemCheckState呼び出されて CheckState が Indeterminate設定され残りの項目については SetItemChecked呼び出されチェック状態が Checked設定されます。

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
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;
}
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.get_Items().get_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;
} //checkEveryOther_Click
継承階層継承階層
System.Object
   System.Windows.Forms.ListBox.ObjectCollection
    System.Windows.Forms.CheckedListBox.ObjectCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からCheckedListBox.ObjectCollection クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCheckedListBox.ObjectCollection クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCheckedListBox.ObjectCollection クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CheckedListBox.ObjectCollection クラス」の関連用語

CheckedListBox.ObjectCollection クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CheckedListBox.ObjectCollection クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS