visual stadio 2019 visual basic windows Form アプリケーション を使用しています。
やりたいこと
模擬モバイルオーダーのformアプリケーションを作成しています。form1で食べ物の写真をクリックするとform2が開き、20種類のドリンクから選んでサイズを選択し、form2に作成したButton1をクリックするとform1のlistboxに
商品名/ドリンク名,サイズ を表示するプログラムを作成しています。なお選択にはRadioButtonにはドリンク名がありそれをGroupBoxで囲む。写真の選択ではPictureBoxを使用しています。
質問
form2で選択したRadioButtonをform1のListboxに商品名/ドリンク名,サイズ のように出力する方法が分かりません。下記、form2 のプログラムになります。ご教授お願いします。
visual
1コード 2 3 Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load 4 connectcontroles() 5 connectevents() 6 End Sub 7 8 Private radiobutton() As System.Windows.Forms.RadioButton 9 Private Sub connectcontroles() 10 radiobutton = New System.Windows.Forms.RadioButton(20) {} 11 radiobutton(1) = RadioButton1 12 radiobutton(2) = RadioButton2 13 radiobutton(3) = RadioButton3 14 radiobutton(4) = RadioButton4 15 radiobutton(5) = RadioButton5 16 radiobutton(6) = RadioButton6 17 radiobutton(7) = RadioButton7 18 radiobutton(8) = RadioButton8 19 radiobutton(9) = RadioButton9 20 radiobutton(10) = RadioButton10 21 radiobutton(11) = RadioButton11 22 radiobutton(12) = RadioButton12 23 radiobutton(13) = RadioButton13 24 radiobutton(14) = RadioButton14 25 radiobutton(15) = RadioButton15 26 radiobutton(16) = RadioButton16 27 radiobutton(17) = RadioButton17 28 radiobutton(18) = RadioButton18 29 radiobutton(19) = RadioButton19 30 radiobutton(20) = RadioButton20 31 End Sub 32 33 Private Sub connectevents() 34 For i As Integer = 1 To 20 35 AddHandler radiobutton(i).Click, AddressOf Button1_Click 36 Next 37 End Sub 38 39Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 40 Dim select As String 41 For i As Integer = 1 To 20 42 If RadioButton21.Checked Then 'Sサイズ 43 select = radiobutton(i).Text & "," & RadioButton21.Text 44 ElseIf RadioButton22.Checked Then 'Mサイズ 45 select = radiobutton(i).Text & "," & RadioButton22.Text 46 ElseIf RadioButton23.Checked Then 'Lサイズ 47 select = radiobutton(i).Text & "," & RadioButton23.Text 48 End If 49 Next 50 End Sub
回答2件
あなたの回答
tips
プレビュー