I am a complete novice in vb.net. I have a form with a panel within which sits several user controls. Depending on what activity the user is performing, a different user control is displayed in the panel. No problems.
However, I would like one of the user controls to have 6 buttons, that when pressed, the master form can understand which button has been pressed.
I tried to add an Event to the User Control but it says the handles clause requires a WithEvents variable defined in the containing type or one of its base types. But I couldn't get that working so I've come to you for some help.
Public Class UserControl1
Public Event S1_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Public Sub ButtonG2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonG2.Click
RaiseEvent S1_Button_Click(sender, e)
Public Class Form1
Dim Screen1 As UserControl1
Dim Active_screen As System.Windows.Forms.Control
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Screen1 = New UserControl1
Active_screen = Screen1
Private Sub Screen1_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Screen1.S1_Button_Click
MsgBox("Button pressed!") <----- Here I want to understand which button was pressed but I've put this to just get it going