how do I determine which button was clicked on a prevoius form to access the form I am currently working on?
-
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist :)
-
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist :)
When you instantiate the form you can pass the button id or a value for each button to the sub new in the calling form
oFrm = New frmPFElement(iID)
Constructor in the called formSub New(ByVal iID As Integer) ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. mvID = iID End Sub
-
When you instantiate the form you can pass the button id or a value for each button to the sub new in the calling form
oFrm = New frmPFElement(iID)
Constructor in the called formSub New(ByVal iID As Integer) ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. mvID = iID End Sub
-
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist :)
Just set the click event for both buttons then do a select case on the sender object of the event like below:
private sub form_Click(ByVal send as System.Object, ByVal e as System.EventArgs)Handles form1Btn.Click, form2Btn.Click Select Case sender.name Case "form1" 'do something here Case "form2" 'do something else End Select End Sub
That should do it. I did this for an airplane seating chart. Worked great. Each seat was really a button and once it was taken I put a big red X on it to show that is was not avaliable. TomTom Wright tawright915@gmail.com