Bagikan melalui


CheckedListBox.ObjectCollection Kelas

Definisi

Mewakili kumpulan item dalam 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
Warisan
CheckedListBox.ObjectCollection

Contoh

Contoh berikut menghitung item dalam CheckedListBox dan memeriksa setiap item lain dalam daftar. Contoh menunjukkan penggunaan Items properti untuk mendapatkan CheckedListBox.ObjectCollection untuk mendapatkan Count item.

Contoh ini juga menunjukkan menggunakan SetItemCheckState metode dan SetItemChecked untuk mengatur status pemeriksaan item. Untuk setiap item lain yang akan diperiksa, SetItemCheckState dipanggil untuk mengatur CheckState ke Indeterminate, sementara SetItemChecked dipanggil pada item lain untuk mengatur status dicentang ke 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

Keterangan

Koleksi diakses dari kontrol induk, CheckedListBox, oleh Items properti . Untuk membuat kumpulan objek yang akan ditampilkan dalam CheckedListBox kontrol, Anda dapat menambahkan atau menghapus item satu per satu dengan menggunakan Add metode dan Remove .

Konstruktor

Nama Deskripsi
CheckedListBox.ObjectCollection(CheckedListBox)

Menginisialisasi instans baru dari kelas CheckedListBox.ObjectCollection.

Properti

Nama Deskripsi
Count

Mendapatkan jumlah item dalam koleksi.

(Diperoleh dari ListBox.ObjectCollection)
IsReadOnly

Mendapatkan nilai yang menunjukkan apakah koleksi bersifat baca-saja.

(Diperoleh dari ListBox.ObjectCollection)
Item[Int32]

Mendapatkan atau mengatur item pada indeks yang ditentukan dalam koleksi.

(Diperoleh dari ListBox.ObjectCollection)

Metode

Nama Deskripsi
Add(Object, Boolean)

Menambahkan item ke daftar item untuk CheckedListBox, menentukan objek yang akan ditambahkan dan apakah item tersebut dicentang.

Add(Object, CheckState)

Menambahkan item ke daftar item untuk CheckedListBox, menentukan objek yang akan ditambahkan dan nilai awal yang dicentang.

Add(Object)

Menambahkan item ke daftar item untuk ListBox.

(Diperoleh dari ListBox.ObjectCollection)
AddRange(ListBox+ObjectCollection)

Menambahkan item dari item yang sudah ada ListBox.ObjectCollection ke daftar item dalam ListBox.

(Diperoleh dari ListBox.ObjectCollection)
AddRange(Object[])

Menambahkan array item ke daftar item untuk ListBox.

(Diperoleh dari ListBox.ObjectCollection)
Clear()

Menghapus semua item dari koleksi.

(Diperoleh dari ListBox.ObjectCollection)
Contains(Object)

Menentukan apakah item yang ditentukan terletak di dalam koleksi.

(Diperoleh dari ListBox.ObjectCollection)
CopyTo(Object[], Int32)

Menyalin seluruh koleksi ke dalam array objek yang ada di lokasi tertentu dalam array.

(Diperoleh dari ListBox.ObjectCollection)
Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetEnumerator()

Mengembalikan enumerator yang akan digunakan untuk melakukan iterasi melalui kumpulan item.

(Diperoleh dari ListBox.ObjectCollection)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan Type instans saat ini.

(Diperoleh dari Object)
IndexOf(Object)

Mengembalikan indeks dalam kumpulan item yang ditentukan.

(Diperoleh dari ListBox.ObjectCollection)
Insert(Int32, Object)

Menyisipkan item ke dalam kotak daftar pada indeks yang ditentukan.

(Diperoleh dari ListBox.ObjectCollection)
MemberwiseClone()

Membuat salinan dangkal dari Objectsaat ini.

(Diperoleh dari Object)
Remove(Object)

Menghapus objek yang ditentukan dari koleksi.

(Diperoleh dari ListBox.ObjectCollection)
RemoveAt(Int32)

Menghapus item pada indeks yang ditentukan dalam koleksi.

(Diperoleh dari ListBox.ObjectCollection)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Implementasi Antarmuka Eksplisit

Nama Deskripsi
ICollection.CopyTo(Array, Int32)

API ini mendukung infrastruktur produk dan tidak dimaksudkan untuk digunakan langsung dari kode Anda.

Menyalin elemen koleksi ke array, dimulai pada indeks array tertentu.

(Diperoleh dari ListBox.ObjectCollection)
ICollection.IsSynchronized

Untuk deskripsi anggota ini, lihat IsSynchronized.

(Diperoleh dari ListBox.ObjectCollection)
ICollection.SyncRoot

Untuk deskripsi anggota ini, lihat SyncRoot.

(Diperoleh dari ListBox.ObjectCollection)
IList.Add(Object)

API ini mendukung infrastruktur produk dan tidak dimaksudkan untuk digunakan langsung dari kode Anda.

Menambahkan objek ke ListBox kelas .

(Diperoleh dari ListBox.ObjectCollection)
IList.Contains(Object)

Menentukan apakah IList berisi nilai tertentu.

(Diperoleh dari ListBox.ObjectCollection)
IList.IndexOf(Object)

Menentukan indeks item tertentu di IList.

(Diperoleh dari ListBox.ObjectCollection)
IList.Insert(Int32, Object)

Menyisipkan item ke IList pada indeks yang ditentukan.

(Diperoleh dari ListBox.ObjectCollection)
IList.IsFixedSize

Untuk deskripsi anggota ini, lihat IsFixedSize.

(Diperoleh dari ListBox.ObjectCollection)
IList.Item[Int32]

Mendapatkan atau mengatur elemen pada indeks yang ditentukan.

(Diperoleh dari ListBox.ObjectCollection)
IList.Remove(Object)

Menghapus kemunculan pertama objek tertentu dari IList.

(Diperoleh dari ListBox.ObjectCollection)

Metode Ekstensi

Nama Deskripsi
AsParallel(IEnumerable)

Mengaktifkan paralelisasi kueri.

AsQueryable(IEnumerable)

Mengonversi IEnumerable menjadi IQueryable.

Cast<TResult>(IEnumerable)

Melemparkan elemen IEnumerable ke jenis yang ditentukan.

OfType<TResult>(IEnumerable)

Memfilter elemen IEnumerable berdasarkan jenis tertentu.

Berlaku untuk