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. Invoking a Button_Click() event from a seperate form

Invoking a Button_Click() event from a seperate form

Scheduled Pinned Locked Moved Visual Basic
helpquestion
24 Posts 7 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.
  • D Dave Kreskowiak

    nlarson11 wrote:

    when formB is a modal form and it's answer will dictate what formA will do...

    Then FormB exposes it's status as properties. FormA then decides what it's going to do with that data and alters its own user interface accordingly. FormB should never know anything about the form that launched it.

    A guide to posting questions on CodeProject[^]
    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
         2006, 2007

    N Offline
    N Offline
    nlarson11
    wrote on last edited by
    #21

    I think we missed/missing each other's points. if i'm in formA and I create and instance of formB, I have 2 options of displaying formB... SHOW and SHOWDIALOG if i use SHOW then you are correct, formB shouldn't need to know anything about A but if it does, use a delegate. if I use SHOWDIALOG that A is waiting for B to respond with the user's choice of pressing OK or Cancel or whatever choices remain in the enum dialogresult. So B will return the answer and A reacts accordingly. No different then an OK/Cancel messagebox. I personally have no issue with A reacting to B in this situation...

    D 1 Reply Last reply
    0
    • N nlarson11

      I think we missed/missing each other's points. if i'm in formA and I create and instance of formB, I have 2 options of displaying formB... SHOW and SHOWDIALOG if i use SHOW then you are correct, formB shouldn't need to know anything about A but if it does, use a delegate. if I use SHOWDIALOG that A is waiting for B to respond with the user's choice of pressing OK or Cancel or whatever choices remain in the enum dialogresult. So B will return the answer and A reacts accordingly. No different then an OK/Cancel messagebox. I personally have no issue with A reacting to B in this situation...

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #22

      Whoops! Sorry, I misread your previous post. We're both on the same page!

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      N 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Whoops! Sorry, I misread your previous post. We're both on the same page!

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        N Offline
        N Offline
        nlarson11
        wrote on last edited by
        #23

        good. i normally agree with you 100% :doh:

        1 Reply Last reply
        0
        • R reegan41

          Hi, I have two seperate forms. Lets just call them FormA and FormB. I have a function in FormA called Button_Click(). How would I (while in FormB) call this function? I have tried, while in the FormB code, using Form_FormA.Button_Click. But that doesn't seem to work. Can anyone help me with this?

          N Offline
          N Offline
          Naji El Kotob
          wrote on last edited by
          #24

          Hi, this is a way that you can use if you are calling formB from formA, if not you can use the Sub Main to keep active forms references. In FormB Private m_f As FormA Public Sub New(f as FormA) m_f = f MyBase.New End Sub ... Call m_f.TheMethod In FormA ...ButtonX.Click Call TheMethod End Sub Public Sub TheMethod ... End Sub ... dim f as New FromB(Me) f.Show Hope this helps! NajiCo http://www.InsideVB.NET[^]

          It's nice 2b important, but it's more important 2b nice...

          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