Thread: Populating struct from second form

  1. #1
    Registered User verbity's Avatar
    Join Date
    Nov 2006
    Posts
    101

    Red face Populating struct from second form

    I'm having issues with filling a struct from a textbox in a different form.

    it's just a textbox with a string....

    Do I use the get/set methods?? and if so how the heck do I call the get method?

    if I do

    Code:
    public string getThis String
    {
        get
        {
               return thisString;
         }
    }
    Do is call it like Form2.getThisString()???? Or what???

    Dammitt!!!! Help...a pathetic student/ intern at a software company is in danger of his teacher finding out that he really doesn't deserve his A.

  2. #2
    Registered User verbity's Avatar
    Join Date
    Nov 2006
    Posts
    101

    Re: Where's the Love

    Was my question too easy?? Where's the love...

    I believe if I had that public method with the get and set inside I would just call it (if it was called public string thisString) from the other form like :

    Code:
    form2.thisString;
    and that will automatically call the get function and assign whatever string if I have a statement like:
    Code:
    thisStruct[1].thisStringAssignment = form2.thisString;
    Or at least I think so....

    Gotta debug and see if that works out....but feel free to tel me if I'm wrong please!!

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    You write those methods like this
    Code:
    //Held within a Form2 class
    public string specialString
    {
        get{ return this.mSpecialString; }
    }
    And to call it
    Code:
    Form2 myForm2 = new Form2();
    
    string special = myForm2.specialString;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with linked list sorting function
    By Jaggid1x in forum C Programming
    Replies: 6
    Last Post: 06-02-2009, 02:14 AM
  2. passing a Struct from one Form to another?
    By Cielo in forum Windows Programming
    Replies: 5
    Last Post: 03-13-2008, 06:31 PM
  3. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Binary Search Tree
    By penance in forum C Programming
    Replies: 4
    Last Post: 08-05-2005, 05:35 PM