CheckedChanged イベントを発生させます。
Protected Overridable Sub OnCheckedChanged( _
ByVal e As EventArgs _)
[C#]
protected virtual void OnCheckedChanged(EventArgse);
[C++]
protected: virtual void OnCheckedChanged(EventArgs* e);
[JScript]
protected function OnCheckedChanged(
e : EventArgs);
パラメータ
- e
イベント データを格納している EventArgs 。
解説
イベントが発生すると、デリゲートを使用してイベント ハンドラが呼び出されます。詳細については、「 イベントの発生 」を参照してください。
OnCheckedChanged メソッドを使用すると、デリゲートを結び付けずに、派生クラスでイベントを処理させることもできます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
継承時の注意: 派生クラスで OnCheckedChanged をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnCheckedChanged メソッドを呼び出してください。
使用例
[Visual Basic, C#, C++] CheckAlign プロパティを実行時に変更する方法を次の例に示します。 Checked 値が変更されると、オプション ボタン コントロールのチェック ボックス部分がテキストの左右に移動します。このコードは、 RadioButton コントロールがフォーム上でインスタンス化されていること、および System.Drawing 名前空間への参照が含まれていることを前提にしています。
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
[C#]
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;
}
}
[C++]
private: System::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;
}
}
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
RadioButton クラス | RadioButton メンバ | System.Windows.Forms 名前空間