Reputation: 79
I want the user to click on a radio button and then click the submit button. Once the submit button is pressed it changes a textbox value. However Visual Studio is telling me that I need to use a 'Raised Event'. I don't know how to use that or is it even needed? Here is the code:
Private Sub create_Click(sender As Object, e As RoutedEventArgs)
If RadioButton1.Checked = True Then
Me.creflag.Text += "1"
ElseIf RadioButton2.Checked = True Then
Me.creflag.Text += "4224"
ElseIf RadioButton3.Checked = True Then
Me.creflag.Text += "2"
ElseIf RadioButton4.Checked = True Then
Me.immune.Text += "619659263"
Me.typeflag.Text += "4"
End If
End Sub
Upvotes: 2
Views: 2112
Reputation: 79
Ok so I found out that I was mixing windows forms and WPF together. In windows forms it's .Checked but in WPF that is an event thus why it was giving me errors. The correct way in WPF is .IsChecked
Final Code:
Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs) Handles Button.Click
If RadioButton1.IsChecked = True Then
Me.creflag.Text += "1"
ElseIf RadioButton2.IsChecked = True Then
Me.creflag.Text += "4224"
ElseIf RadioButton3.IsChecked = True Then
Me.creflag.Text += "2"
ElseIf RadioButton4.IsChecked = True Then
Me.immune.Text += "619659263"
Me.typeflag.Text += "4"
End If
End Sub
Upvotes: 0
Reputation: 216343
In your XAML markup you have
.... Click="Button_Click"
this means that you need to have a RouterEventHandler named Button_Click not create_Click
Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
If RadioButton1.Checked = True Then
Me.creflag.Text += "1"
ElseIf RadioButton2.Checked = True Then
Me.creflag.Text += "4224"
ElseIf RadioButton3.Checked = True Then
Me.creflag.Text += "2"
ElseIf RadioButton4.Checked = True Then
Me.immune.Text += "619659263"
Me.typeflag.Text += "4"
End If
End Sub
Upvotes: 1