Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Kontrol Windows Forms CheckBox digunakan untuk memberi pengguna opsi True/False atau Ya/Tidak. Kontrol menampilkan tanda centang saat dipilih.
Untuk mengatur opsi dengan kontrol Kotak Centang
Periksa nilai properti untuk menentukan statusnya, dan gunakan nilai tersebut Checked untuk mengatur opsi.
Dalam sampel kode di bawah ini, saat CheckBox peristiwa kontrol CheckedChanged dinaikkan, properti formulir AllowDrop diatur ke
false
jika kotak centang dicentang. Ini berguna untuk situasi di mana Anda ingin membatasi interaksi pengguna.Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged ' Determine the CheckState of the check box. If CheckBox1.CheckState = CheckState.Checked Then ' If checked, do not allow items to be dragged onto the form. Me.AllowDrop = False End If End Sub
private void checkBox1_CheckedChanged(object sender, System.EventArgs e) { // Determine the CheckState of the check box. if (checkBox1.CheckState == CheckState.Checked) { // If checked, do not allow items to be dragged onto the form. this.AllowDrop = false; } }
private: void checkBox1_CheckedChanged(System::Object ^ sender, System::EventArgs ^ e) { // Determine the CheckState of the check box. if (checkBox1->CheckState == CheckState::Checked) { // If checked, do not allow items to be dragged onto the form. this->AllowDrop = false; } }
Lihat juga
- CheckBox
- Gambaran Umum Kontrol Kotak Centang
- Panduan: Merespons Klik Kotak Centang pada Windows Forms
- Kontrol Kotak Centang
.NET Desktop feedback