Sdílet prostřednictvím


RadioButton.OnCheckedChanged(EventArgs) Metoda

Definice

CheckedChanged Vyvolá událost.

protected:
 virtual void OnCheckedChanged(EventArgs ^ e);
protected virtual void OnCheckedChanged(EventArgs e);
abstract member OnCheckedChanged : EventArgs -> unit
override this.OnCheckedChanged : EventArgs -> unit
Protected Overridable Sub OnCheckedChanged (e As EventArgs)

Parametry

e
EventArgs

Obsahuje EventArgs data události.

Příklady

Následující příklad kódu ukazuje, jak CheckAlign lze vlastnost změnit za běhu. Při změně hodnoty se část zaškrtávacího políčka přesune RadioButton do pravého nebo levého textu Checked . Tento příklad vyžaduje vytvoření RadioButton instance ovládacího prvku ve formuláři a zahrnutí odkazu na System.Drawing obor názvů.

private:
   Void radioButton1_CheckedChanged( System::Object^ sender, System::EventArgs^ e )
   {
      // Change the check box position to be opposite its current position.
      if ( radioButton1->CheckAlign == ContentAlignment::MiddleLeft )
      {
         radioButton1->CheckAlign = ContentAlignment::MiddleRight;
      }
      else
      {
         radioButton1->CheckAlign = ContentAlignment::MiddleLeft;
      }
   }
private void radioButton1_CheckedChanged(Object sender, 
                                         EventArgs e)
{
   /* Change the check box position to 
   be the opposite its current position.*/
   if (radioButton1.CheckAlign == ContentAlignment.MiddleLeft)
   {
      radioButton1.CheckAlign = ContentAlignment.MiddleRight;
   }
   else
   {
      radioButton1.CheckAlign = ContentAlignment.MiddleLeft;
   }
}
Private Sub radioButton1_CheckedChanged(sender As Object, e As EventArgs)
    ' Change the check box position to
    ' be the opposite its current position.
    If radioButton1.CheckAlign = ContentAlignment.MiddleLeft Then
        radioButton1.CheckAlign = ContentAlignment.MiddleRight
    Else
        radioButton1.CheckAlign = ContentAlignment.MiddleLeft
    End If
End Sub

Poznámky

Vyvolání události vyvolá obslužnou rutinu události prostřednictvím delegáta. Další informace naleznete v tématu Zpracování a vyvolávání událostí.

Metoda OnCheckedChanged také umožňuje odvozené třídy zpracovat událost bez připojení delegáta. Toto je upřednostňovaná technika pro zpracování události v odvozené třídě.

Poznámky pro dědice

Při přepsání OnCheckedChanged(EventArgs) v odvozené třídě nezapomeňte volat metodu základní třídy OnCheckedChanged(EventArgs) , aby zaregistrovaní delegáti obdrželi událost.

Platí pro