タイトル | : Re: RadioButton のチェックが移動したときのイベント |
記事No | : 6263 |
投稿日 | : 2007/09/10(Mon) 13:45 |
投稿者 | : 魔界の仮面弁士 |
> On にしてしまうと eventSender.Checked で > コンパイルエラーが発生してしまいます。
===== 案1 ===== Private Sub Options_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles Option1.CheckedChanged, Option2.CheckedChanged
If Option1.Checked AndAlso Option1 Is sender Then Debug.Print("Option1_Click()") ElseIf Option2.Checked AndAlso Option2 Is sender Then Debug.Print("Option2_Click()") End If End Sub
===== 案2 ===== Private Sub Options_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles Option1.CheckedChanged, Option2.CheckedChanged
Dim radio As RadioButton = TryCast(sender, RadioButton) If radio IsNot Nothing AndAlso radio.Checked Then If radio Is Option1 Then Debug.Print("Option1_Click()") ElseIf radio Is Option2 Then Debug.Print("Option2_Click()") End If End If End Sub
===== 案3 ===== Private Sub Option1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles Option1.CheckedChanged
If Option1.Checked Then Debug.Print("Option1_Click()") End If End Sub
Private Sub Option2_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) _ Handles Option2.CheckedChanged
If Option2.Checked Then Debug.Print("Option2_Click()") End If End Sub
|