+ Reply to Thread
Results 1 to 2 of 2

Thread: passing data between forms

  1. #1
    Newbie Dawn is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    1

    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 06:11 PM. Reason: add code tags (the # button)

  2. #2
    Code Warrior dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta has much to be proud of dargueta's Avatar
    Join Date
    Oct 2007
    Age
    19
    Posts
    2,847
    Blog Entries
    8

    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.
    Coding without commenting is like throwing up. You're making a mess that'll be fun to clean up.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. C#:Tutorial - Download Data
    By Xav in forum CSharp Tutorials
    Replies: 13
    Last Post: 02-11-2010, 02:17 PM
  2. Data base or xml ?
    By zeroradius in forum Database & Database Programming
    Replies: 2
    Last Post: 12-28-2008, 10:09 AM
  3. Choosing the right language / data structure / Interface
    By ups in forum General Programming
    Replies: 1
    Last Post: 09-20-2008, 09:11 AM
  4. Java:Tutorial - Data Types
    By John in forum Java Tutorials
    Replies: 6
    Last Post: 07-02-2007, 09:16 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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