共用方式為


RadioButton.CheckedChanged 事件

定義

發生於 Checked 屬性的值變更時。

public:
 event EventHandler ^ CheckedChanged;
public event EventHandler CheckedChanged;
public event EventHandler? CheckedChanged;
member this.CheckedChanged : EventHandler 
Public Custom Event CheckedChanged As EventHandler 

事件類型

範例

以下程式碼範例展示了如何在執行時更改該 CheckAlign 屬性。 當值改變Checked時,a RadioButton 的勾選框部分會移至文字的右側或左側。 此範例要求在表單上實例化控制 RadioButton 項,且包含對命名 System.Drawing 空間的參考。

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 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 opposite its current position.
    If radioButton1.CheckAlign = ContentAlignment.MiddleLeft Then
        radioButton1.CheckAlign = ContentAlignment.MiddleRight
    Else
        radioButton1.CheckAlign = ContentAlignment.MiddleLeft
    End If
End Sub

備註

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於

另請參閱