VB.NET, C#, PowerShellを使用しているエンジニアのためのサイト。
基本的な使用方法から開発で役立つTipsまで幅広く取り扱っています。
<< 前のTips 次のTips >>
RadioButtonはグループごとに1つしか選択することができません。複数のグループを作成する場合は、GroupBoxコントロールまたは Panelコントロール上にRadioButtonを配置します。(グループ化しないと、フォーム上にあるすべてのRadioButtonはすべて同じグループと見なされてしまいます。)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim rb1, rb2, rb3 As RadioButton Dim msg As String 'GroupBox1で選択されているRadioButtonを取得 For Each rb1 In GroupBox1.Controls If (rb1.Checked) Then msg = "GroupBox1では" & rb1.Text & "がチェックされています。" & ControlChars.NewLine End If Next 'GroupBox2で選択されているRadioButtonを取得 For Each rb2 In GroupBox2.Controls If (rb2.Checked) Then msg &= "GroupBox2では" & rb2.Text & "がチェックされています。" & ControlChars.NewLine End If Next 'Panel1で選択されているRadioButtonを取得 For Each rb3 In Panel1.Controls If (rb3.Checked) Then msg &= "Panel1では" & rb3.Text & "がチェックされています。" & ControlChars.NewLine End If Next MessageBox.Show(msg) End Sub
<< 前のTips 次のTips >>