Closed Thread
Results 1 to 2 of 2

Thread: passing data between forms

  1. #1
    Dawn is offline Newbie
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    passing data between forms

    Hi,

    I have 7 forms in my project. Form 6 has a text box, I wish for the text entered in Form 6 to be passed to a label in Form 7. I am new to C++ and would really appreciate any advice. I have posted the code I am trying to work with but i keep getting error C2248. Please Help!! Thanks.
    Code:
    public ref class Form6 : public System::Windows::Forms::Form
    {
    public:String^str1;
    
    public: 
    
    Form6(void)
    
    
    {
    
    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }
    #pragma endregion
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    
    Application::Exit();
    }
    private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
    
    Application::Exit();
    }
    private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
    }
    private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
    
    this->textBox2->Text = this->textBox1->Text;
    this->textBox1->Text = "";
    this->textBox1->Text = "Saved";
    } 
    private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    }
    public: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
    str1 = this->textBox2->text;
    Form6::Hide();
    Form7 myForm;
    if(myForm.ShowDialog() == System::Windows::Forms::DialogResult::OK)
    
    {
    //Do stuff
    }
    }
    private: System::Void Form6_Load(System::Object^ sender, System::EventArgs^ e) {
    str1 = "str1default";
    }
    private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
    str1=textBox2->Text;
    }
    };
    }
    Last edited by WingedPanther; 02-08-2009 at 04:11 PM. Reason: add code tags (the # button)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: passing data between forms

    Change the member describing the textbox to protected instead of private and declare Form7 as a friend of the Form6 class.
    sudo rm -rf /

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Passing data to Forms
    By jireland in forum C# Programming
    Replies: 3
    Last Post: 12-06-2010, 06:17 AM
  2. Replies: 3
    Last Post: 08-21-2010, 02:59 AM
  3. Replies: 0
    Last Post: 12-06-2009, 02:13 AM
  4. Data Masking helps in reducing data privacy violations
    By tossy in forum Software Security
    Replies: 1
    Last Post: 07-06-2009, 05:52 PM
  5. Replies: 6
    Last Post: 02-03-2009, 10:39 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts