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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Easy:reference values after dialog show

Easy:reference values after dialog show

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • E Offline
    E Offline
    EdgarBM
    wrote on last edited by
    #1

    Hi, I think my problem is easy to solve, but I'm giving too much time while I can solve it in other ways (uglier ones...). That's it: I've got a form which instantiates a simple form to get a user & pwd. When the Show method is finished I would like to get the values of the strings (properties) in the calling form. I can do it creating two public strings at the called form which are initialized to the Edit Controls value and read by the calling form when the Show method finishes. It's a simple solution, but I want a better one: Is it possible to pass the reference of the local strings to the constructor of the called form so when the Show method finishes the calling form already has the initialized values? I also tried to use Marshal interface and IntPtr, but the solution became uglier by moments... Does anyone know how to manage it?, is it possible?, maybe is there any similar solution which save me to create to public strings in the called form? Thank you in advance, Edgar __________________________________________ Edgar Berengena Moreno Software Engineer Appeyron Research

    S 1 Reply Last reply
    0
    • E EdgarBM

      Hi, I think my problem is easy to solve, but I'm giving too much time while I can solve it in other ways (uglier ones...). That's it: I've got a form which instantiates a simple form to get a user & pwd. When the Show method is finished I would like to get the values of the strings (properties) in the calling form. I can do it creating two public strings at the called form which are initialized to the Edit Controls value and read by the calling form when the Show method finishes. It's a simple solution, but I want a better one: Is it possible to pass the reference of the local strings to the constructor of the called form so when the Show method finishes the calling form already has the initialized values? I also tried to use Marshal interface and IntPtr, but the solution became uglier by moments... Does anyone know how to manage it?, is it possible?, maybe is there any similar solution which save me to create to public strings in the called form? Thank you in advance, Edgar __________________________________________ Edgar Berengena Moreno Software Engineer Appeyron Research

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

      Default param passing is by ref, so nothing prevents you from the caller Form to do this :

      Form2 f = new Form2();
      f.SetFormData(m_arrayData);
      f.Show();

      where m_arrayData is whatever collection, such as System.Collections.ArrayList for instance. Be warned though that .Show() returns immediately after the Form is displayed, thus you never know when the collection is updated, etc. Unless instead of passing a collection, you pass a class with a collection member and a SetDirty() method to tell the caller. Another interesting point is that the Form2 subform should not call you, but instead raise an event the caller Form has subscribed for. That's much more standard C#/Java programming-style. See http://www.codeproject.com/csharp/delegates-part1.asp[^]


      And I swallow a small raisin.

      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