Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
En Windows Forms-CheckBox-kontroll används för att ge användarna true/false- eller ja/nej-alternativ. Kontrollen visar en bockmarkering när den är markerad.
Ange alternativ med CheckBox-kontroller
Granska värdet för egenskapen Checked för att fastställa dess tillstånd och använd det värdet för att ange ett alternativ.
När CheckBox-händelsen i CheckedChanged-kontrollen utlöses i kodexemplet nedan, ställs formulärets egenskap AllowDrop till
falseom kryssrutan är markerad. Detta är användbart för situationer där du vill begränsa användarinteraktion.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 Subprivate 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; } }
Se även
.NET Desktop feedback