Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. how do I determine which button was clicked on a prevoius form to access the form I am currently working on?

how do I determine which button was clicked on a prevoius form to access the form I am currently working on?

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Oizo
    wrote on last edited by
    #1

    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 :)

    M T 2 Replies Last reply
    0
    • M Mr Oizo

      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 :)

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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 form Sub 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

      M 1 Reply Last reply
      0
      • M Mycroft Holmes

        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 form Sub 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

        M Offline
        M Offline
        Mr Oizo
        wrote on last edited by
        #3

        :) I'll try that thanks.

        1 Reply Last reply
        0
        • M Mr Oizo

          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 :)

          T Offline
          T Offline
          Tom Wright
          wrote on last edited by
          #4

          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. Tom

          Tom Wright tawright915@gmail.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups