共用方式為


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 

事件類型

EventHandler

範例

下列程式碼範例示範如何在 CheckAlign 執行時間變更 屬性。 值變更時 Checked ,的核取方塊部分 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

備註

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

適用於

另請參閱