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. Managed C++/CLI
  4. Passing Data Between Forms, I tried and failed :)

Passing Data Between Forms, I tried and failed :)

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++graphicstutorialquestion
3 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.
  • B Offline
    B Offline
    Badboy22TR
    wrote on last edited by
    #1

    Hi, I tried to pass data between forms in VC++. I want to pass input data from child's textboxes to parent when child form closes. But all i have is errors. Can you tell me where my mistake(s) is ? //R2.h (Parent Form) #include Yeni.h using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace xxx { public ref class R2 : public System::Windows::Forms::Form { ........... auto generated code............. } //The Button which creates Child Form private: System::Void pictureBox2_Click(System::Object^ sender, System::EventArgs^ e) { MdiParent->ActiveMdiChild->Close(); Yeni^ YRForm = gcnew Yeni(); YRForm->MdiParent=this->MdiParent; YRForm->Show();} //The Button in child form, which closes child form private: System::Void Yeni::pictureBox1_Click(System::Object^ sender, YeniUpdateEventArgs^ e) { String^ A = e->Isim; String^ B = e->Soyad; MessageBox::Show(this,"Isim : "+A+"Soyad : "+B,"Durum",MessageBoxButtons::OK); } //Yeni.h (Child Form) (I'm not sure where I should add "delegate") using namespace System; using .......... .... namespace xxx { public: delegate void YeniUpdateHandler(System::Object^ sender, YeniUpdateEventArgs^ e); public: YeniUpdateHandler^ YeniUpdated; public ref class YeniUpdateEventArgs : public System::EventArgs { private: String^ mIsim; private: String^ mSoyad; public: YeniUpdateEventArgs(String^ sIsim, String^ sSoyad) { this->mIsim = sIsim; this->mSoyad = sSoyad; } public: property String^ Isim { String^ get { return mIsim; } } public: property String^ Soyad { String^ get { return mSoyad; } } }; public ref class Yeni : public System::Windows::Forms::Form { ........... auto generated code............. } //The Button which closes child form private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) { String^ sIsim = textBox1->Text; String^ sSoyad = textBox2->Text; YeniUpdateEventArgs^ args = gcnew YeniUpdateEventArgs(sIsim, sSoyad); YeniUpdated(this, args); this->Close(); } I have 84 errors :)) Most of them is syntax errors. What are my mistakes ? Is anything missing in code or did i place smtg wrong? Thank you very much... PS:Please don't suggest any solution or example in VC#, becau

    P 1 Reply Last reply
    0
    • B Badboy22TR

      Hi, I tried to pass data between forms in VC++. I want to pass input data from child's textboxes to parent when child form closes. But all i have is errors. Can you tell me where my mistake(s) is ? //R2.h (Parent Form) #include Yeni.h using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace xxx { public ref class R2 : public System::Windows::Forms::Form { ........... auto generated code............. } //The Button which creates Child Form private: System::Void pictureBox2_Click(System::Object^ sender, System::EventArgs^ e) { MdiParent->ActiveMdiChild->Close(); Yeni^ YRForm = gcnew Yeni(); YRForm->MdiParent=this->MdiParent; YRForm->Show();} //The Button in child form, which closes child form private: System::Void Yeni::pictureBox1_Click(System::Object^ sender, YeniUpdateEventArgs^ e) { String^ A = e->Isim; String^ B = e->Soyad; MessageBox::Show(this,"Isim : "+A+"Soyad : "+B,"Durum",MessageBoxButtons::OK); } //Yeni.h (Child Form) (I'm not sure where I should add "delegate") using namespace System; using .......... .... namespace xxx { public: delegate void YeniUpdateHandler(System::Object^ sender, YeniUpdateEventArgs^ e); public: YeniUpdateHandler^ YeniUpdated; public ref class YeniUpdateEventArgs : public System::EventArgs { private: String^ mIsim; private: String^ mSoyad; public: YeniUpdateEventArgs(String^ sIsim, String^ sSoyad) { this->mIsim = sIsim; this->mSoyad = sSoyad; } public: property String^ Isim { String^ get { return mIsim; } } public: property String^ Soyad { String^ get { return mSoyad; } } }; public ref class Yeni : public System::Windows::Forms::Form { ........... auto generated code............. } //The Button which closes child form private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) { String^ sIsim = textBox1->Text; String^ sSoyad = textBox2->Text; YeniUpdateEventArgs^ args = gcnew YeniUpdateEventArgs(sIsim, sSoyad); YeniUpdated(this, args); this->Close(); } I have 84 errors :)) Most of them is syntax errors. What are my mistakes ? Is anything missing in code or did i place smtg wrong? Thank you very much... PS:Please don't suggest any solution or example in VC#, becau

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      What are the 84 errors you are getting?

      "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      B 1 Reply Last reply
      0
      • P Paul Conrad

        What are the 84 errors you are getting?

        "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        B Offline
        B Offline
        Badboy22TR
        wrote on last edited by
        #3

        Thank your for your respond. Finally i solved it. I add a new header to project and move the EventArgs class to there. Now it works...

        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