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. C#
  4. c# multiple forms communication

c# multiple forms communication

Scheduled Pinned Locked Moved C#
questioncsharpwinforms
4 Posts 4 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.
  • I Offline
    I Offline
    ikurtz
    wrote on last edited by
    #1

    greetings, i have 3 forms that need to communicate with each other. what is the best way of achieving this? at present im considering using delegates. your comments are welcome. my app is c# windows forms.

    S D C 3 Replies Last reply
    0
    • I ikurtz

      greetings, i have 3 forms that need to communicate with each other. what is the best way of achieving this? at present im considering using delegates. your comments are welcome. my app is c# windows forms.

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      You can use delegate, events or static. I recommend you use static class if app is not Multi-Thread.

      public static settings
      {
      // No constructor
      public static String Info;
      }

      with this class you must use directly not initialize it.

      Form1_OnLoad(Object sender, EventArgs e)
      {
      settings.Info = "I have set this text to static member of settings class";
      }

      1 Reply Last reply
      0
      • I ikurtz

        greetings, i have 3 forms that need to communicate with each other. what is the best way of achieving this? at present im considering using delegates. your comments are welcome. my app is c# windows forms.

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        Delegates seem good in case it should happen on occurrence of some event.

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        1 Reply Last reply
        0
        • I ikurtz

          greetings, i have 3 forms that need to communicate with each other. what is the best way of achieving this? at present im considering using delegates. your comments are welcome. my app is c# windows forms.

          C Offline
          C Offline
          coolestCoder
          wrote on last edited by
          #4

          If it is a one way communication (i.e. from parent to child) you may consider adding an overloaded constructor. If you want 2 way communication, then delegates would be useful. By the way, what kind of a communication you are talking about ? What objects would be passed to and fro ? Details would be great. Thanks !


          "A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder


          coolestCoder

          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