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. Passing handles of one form to another

Passing handles of one form to another

Scheduled Pinned Locked Moved C#
question
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.
  • S Offline
    S Offline
    spin vector
    wrote on last edited by
    #1

    Hi, I have a principal class with properties and a GUI form. The menu on the form allows the user to pull-up a second form to input property values. How can I transfer the property values (text-box inputs) from the second form to the properties of the first class. I've tried from the principal class (in menu-event code) Form_params fp = new Form_params(); fp.ShowDialog(this); so I pass 'this' to the next class. Is this right and how do I access the handle in the second class? Thanks, -Jay

    D J 2 Replies Last reply
    0
    • S spin vector

      Hi, I have a principal class with properties and a GUI form. The menu on the form allows the user to pull-up a second form to input property values. How can I transfer the property values (text-box inputs) from the second form to the properties of the first class. I've tried from the principal class (in menu-event code) Form_params fp = new Form_params(); fp.ShowDialog(this); so I pass 'this' to the next class. Is this right and how do I access the handle in the second class? Thanks, -Jay

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Your description is confusing to say the least. Are you saying the you want to show a second form that has a bunch of TextBoxs and you want to apply the values of these TextBox to the properties of your first Form??? Easy enough. Expose the vluaes of the TextBox's as Public Properties on your second form. Get the values using these property accessors and assign them to the properties of your form.

      Form2 f2 = new Form2();
      f2.ShowDialog();
      this.Text = f2.TextValue;

      //Form2
      public class Form2 : blah
      {
      public string TextValue
      {
      get
      {
      return this.TextBox3.Text;
      }
      }
      }

      Form Handles will have nothing to do with this at all.

      RageInTheMachine9532
      "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      -- modified at 11:14 Tuesday 7th February, 2006

      1 Reply Last reply
      0
      • S spin vector

        Hi, I have a principal class with properties and a GUI form. The menu on the form allows the user to pull-up a second form to input property values. How can I transfer the property values (text-box inputs) from the second form to the properties of the first class. I've tried from the principal class (in menu-event code) Form_params fp = new Form_params(); fp.ShowDialog(this); so I pass 'this' to the next class. Is this right and how do I access the handle in the second class? Thanks, -Jay

        J Offline
        J Offline
        jinzhecheng
        wrote on last edited by
        #3

        I guess you are wondering how to access the "this" Form_params( Form1 form) { // this refer to the form 1 now ........... }

        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