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. Windows Forms
  4. How to pass data from two or more forms ?

How to pass data from two or more forms ?

Scheduled Pinned Locked Moved Windows Forms
questiontutorial
3 Posts 3 Posters 10 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.
  • G Offline
    G Offline
    game_builder
    wrote on last edited by
    #1

    Hi there I have two forms called form1 and form2 . In form2 I have 10 trackbar . I want to change values in form1 when I change form2 trackbars . How can i do this ? can i select a void in form1 for form2 trackbars ?

    Richard DeemingR U 2 Replies Last reply
    0
    • G game_builder

      Hi there I have two forms called form1 and form2 . In form2 I have 10 trackbar . I want to change values in form1 when I change form2 trackbars . How can i do this ? can i select a void in form1 for form2 trackbars ?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Assuming Form1 creates and displays the Form2 instance, the simplest option would be for Form2 to raise a custom event when the values change. Form1 would subscribe to that event, and update its own values accordingly. Alternatively, Form2 would need a reference to the instance of Form1, and would call a public method on the form to update the values. You'll probably want to use an interface for the reference so that the implementation isn't tied to a single concrete class. Or you could use the Mediator pattern. Form2 would publish a message when its values changed. Form1 would subscribe to that message and update its values accordingly. Transferring information between two forms, Part 1: Parent to Child[^] Transferring information between two forms, Part 2: Child to Parent[^] Transferring information between two forms, Part 3: Child to Child[^] Mediator Design Pattern[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • G game_builder

        Hi there I have two forms called form1 and form2 . In form2 I have 10 trackbar . I want to change values in form1 when I change form2 trackbars . How can i do this ? can i select a void in form1 for form2 trackbars ?

        U Offline
        U Offline
        User 13725500
        wrote on last edited by
        #3

        Can you please send your code? It would be useful to help you. :) Thanks.

        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