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. Sharing data between forms???

Sharing data between forms???

Scheduled Pinned Locked Moved C#
comtutorialquestion
3 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.
  • G Offline
    G Offline
    gman44
    wrote on last edited by
    #1

    Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com

    A S 2 Replies Last reply
    0
    • G gman44

      Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com

      A Offline
      A Offline
      Adam Turner
      wrote on last edited by
      #2

      You can do it a couple of ways depending on the relationship between Form1 and Form2. (e.g. Form1 creates Form2, Form2 creates Form1 or Form3 creates both). For "Form1 creates Form2", you can pass an instance of Form1 to Form2 public Form2 { public Form2(Form1 f) { } } ... and then when Form1 is constructing Form2: Form2 f = new Form2(this); if "Form2 creates Form1", then you can just setup a public property in Form1 that gets the text from the label but you must keep an instance of Form1 as a field in Form2 so that your function can access it. And the "Form3 creates both", then construct Form1 first, and then pass its instance to Form2. --Adam Turner

      1 Reply Last reply
      0
      • G gman44

        Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? Kevin@upgrade1.com

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        kvnsdr wrote: Do you know how to use the data in “textbox1.Text” (Form1) in a method on another form (Form2) all within the same namespace??? That's only a matter of public/protected/private member visibility.

        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