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. Cross Form Method Access

Cross Form Method Access

Scheduled Pinned Locked Moved Visual Basic
csharp
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.
  • N Offline
    N Offline
    nlindley7
    wrote on last edited by
    #1

    I am wondering what the best approach is to consume a method that occurs when a button is clicked on a separate form. The situation is that form1 has an add record button that shows form2. after form2 is filled out/submitted, I need to fire the clear event (triggered by a button on form1), to clear out form 1. I would like to keep the button_click method private as well. TIA Nathan Lindley .NET Aficionado

    C 1 Reply Last reply
    0
    • N nlindley7

      I am wondering what the best approach is to consume a method that occurs when a button is clicked on a separate form. The situation is that form1 has an add record button that shows form2. after form2 is filled out/submitted, I need to fire the clear event (triggered by a button on form1), to clear out form 1. I would like to keep the button_click method private as well. TIA Nathan Lindley .NET Aficionado

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      A delegate is what you need here.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      N 1 Reply Last reply
      0
      • C Christian Graus

        A delegate is what you need here.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        N Offline
        N Offline
        nlindley7
        wrote on last edited by
        #3

        I was thinking something along those lines, thanks for the input, i'll proceed in that direction. Nathan Lindley .NET Aficionado

        S 1 Reply Last reply
        0
        • N nlindley7

          I was thinking something along those lines, thanks for the input, i'll proceed in that direction. Nathan Lindley .NET Aficionado

          S Offline
          S Offline
          Steve
          wrote on last edited by
          #4

          Another way to do this would be to implement an MVP or similar (MVC, Passive Screen, Supervising Controller etc.) pattern. That way you could raise the event from the view, into the associated presenter, which can Notify through a model to anywhere in the application that uses that model. Making the event not dependant on the form. Of course, this might not be viable. It's something to think about though... Take a look here[^] for more info on the patterns

          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