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. Accessing Form Data from another form

Accessing Form Data from another form

Scheduled Pinned Locked Moved C#
designquestionannouncement
2 Posts 2 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.
  • L Offline
    L Offline
    LiamD
    wrote on last edited by
    #1

    I have a main dialog. I then create many new dialog forms which the user interacts with to enter values. I want to be able to retrieve the values that the user enters. I am wondering the best way to design my system to allow access to the values entered by the user in the dialog forms. In my main form, I could add a public access to the dialog form instance. This seems inefficiant and seems to need a lot of effort to maintian. Or perhaps I could update some central class with the entered values. Then I would access that class to retrieve the values. I am sure this is a common thing that has to be done. Does anyone have suggestion as to the best way to achieve this? Thanks, Liam

    R 1 Reply Last reply
    0
    • L LiamD

      I have a main dialog. I then create many new dialog forms which the user interacts with to enter values. I want to be able to retrieve the values that the user enters. I am wondering the best way to design my system to allow access to the values entered by the user in the dialog forms. In my main form, I could add a public access to the dialog form instance. This seems inefficiant and seems to need a lot of effort to maintian. Or perhaps I could update some central class with the entered values. Then I would access that class to retrieve the values. I am sure this is a common thing that has to be done. Does anyone have suggestion as to the best way to achieve this? Thanks, Liam

      R Offline
      R Offline
      Russell Jones
      wrote on last edited by
      #2

      There are loads of ways of doing this, here are 2 The simplest and worst of them is to change your controls to be public (I think this works, but would not recommend it) Expose some public properties on your form to read the variables. eg. public string MyTextBoxValue { get { return TextBox1.Text; } } you can also do clever things with a static factory method on the form which takes parameters as refs HTH Russ

      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