Get String^ From Another Forms textBox1

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Get String^ From Another Forms textBox1

 
0
  #1
Jul 8th, 2008
I have Form1 and Form2 in my project. On Form1 I open Form2 like this:
  1. Form2^form2 = gcnew Form2;
  2. form2->Show();

In the Form2:s LoadEvent I use this code so this Form2 will be Active/Shown even that I click on Form1:
  1. private: System::Void Form2_Load(System::Object^ sender, System::EventArgs^ e)
  2. {
  3. Form2::TopMost::set(true);
  4. }

Now is my question this. If I have a textBox1 on Form2 with a written text inside. How can it be possible to reach this text from a button on Form1.

Usually you could have written like this if the textBox was on Form1 in this case:
  1. String^ GetText = textBox1->Text;
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Get String^ From Another Forms textBox1

 
1
  #2
Jul 8th, 2008
I do recall reading one of your threads that asked basically the same question and received a good answer (an answer which would solve your current similar problem). Perhaps you should take the time to learn the concepts of the answers you're given rather than just slapping the example code into your project and hacking it into submission.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Get String^ From Another Forms textBox1

 
0
  #3
Jul 8th, 2008
I am not sure if you could meen that I can get the String from Form2, beginning with the
FormClass and then the textBox like this.
I can find the richTextBox1 as a member and I have declared the richTextBox as public on Form2:
If I write the first example. The compiler says.
left of '->Text' must point to class/struct/union/generic type
  1. #include "Form2.h"
  2. String^ GetText = Form2::richTextBox1->Text;




Originally Posted by Narue View Post
I do recall reading one of your threads that asked basically the same question and received a good answer (an answer which would solve your current similar problem). Perhaps you should take the time to learn the concepts of the answers you're given rather than just slapping the example code into your project and hacking it into submission.
Last edited by Jennifer84; Jul 8th, 2008 at 2:50 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Get String^ From Another Forms textBox1

 
1
  #4
Jul 8th, 2008
>I am not sure if you could meen that I can get the String from Form2
What I mean is that you need to engage your brain around here, because you've been told how to pass data between two forms before: use properties or events. Generally, if you ask the same question multiple times, we assume you're nothing but a mindless leech looking for quick answers, and nobody will want to help you.

>I have declared the richTextBox as public on Form2
That's about the worst possible solution. If you have to make private data public, you're doing something wrong.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Get String^ From Another Forms textBox1

 
0
  #5
Jul 8th, 2008
>> we assume you're nothing but a mindless leech looking for quick answers

I beleive it is important that I mention something here. I am not looking for quick answers.
If I have passed data between forms before I would be happy to know what question that was because I have left out this question for 2 months. The only things I do is to read and write to files.
This is the only way I communicate between the Forms, passing strings and text right now through textfiles.
For the moment I dont know any other way.
Perheps I have done this or something simular in a way I haven´t thought of ofcourse.
I will check the properties and events now and it could be a good way as you say to experiment around and see if I can solve it myself. I will do this.
One way I know I can do is to to use the event Text_Changed that writes all contents to a file each time you write something and then I can read this file.

j


Originally Posted by Narue View Post
>I am not sure if you could meen that I can get the String from Form2
What I mean is that you need to engage your brain around here, because you've been told how to pass data between two forms before: use properties or events. Generally, if you ask the same question multiple times, we assume you're nothing but a mindless leech looking for quick answers, and nobody will want to help you.

>I have declared the richTextBox as public on Form2
That's about the worst possible solution. If you have to make private data public, you're doing something wrong.
Last edited by Jennifer84; Jul 8th, 2008 at 3:40 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,867
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 755
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Senior Bitch

Re: Get String^ From Another Forms textBox1

 
1
  #6
Jul 8th, 2008
>I am not looking for quick answers.
So slow ones will do?

>If I have passed data between forms before I would be happy to know what
>question that was because I have left out this question for 2 months.
I remember reading a thread where a public property in one form allowed another form to get private data. You're one of the few people who asks about C++/CLI on this forum, and I'm pretty sure it was you, though I could be wrong.

>This is the only way I communicate between the Forms,
>passing strings and text right now through textfiles.
Read up on properties. I can only mention it so many times before I get tired of my advice being ignored.
New members chased away this month: 5
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Get String^ From Another Forms textBox1

 
0
  #7
Jul 8th, 2008
Thanks Narue, I will read the properties and also my previous posts to see if I can find anything. I dont want to be to sure myself either and really understand its tiring to answer the same questions.

I found one thread where I did ask how to declare a managed vector to be reached from two buttoncontrols. I would fill the vector from one buttoncontrol on the form and the second buttoncontrol on the same form would read the contents that the vector stored.
I am not really sure about the meening with private and public so I just wrote public like below.
So I had to declare it in managed because it had to be declared ´outside´ the buttoncode.
This I remember I asked but this perheps wasn´t the one.

public: System::Collections::Generic::List<double> OneVector;


Originally Posted by Narue View Post
>I am not looking for quick answers.
So slow ones will do?

>If I have passed data between forms before I would be happy to know what
>question that was because I have left out this question for 2 months.
I remember reading a thread where a public property in one form allowed another form to get private data. You're one of the few people who asks about C++/CLI on this forum, and I'm pretty sure it was you, though I could be wrong.

>This is the only way I communicate between the Forms,
>passing strings and text right now through textfiles.
Read up on properties. I can only mention it so many times before I get tired of my advice being ignored.
Last edited by Jennifer84; Jul 8th, 2008 at 5:18 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1295 | Replies: 6
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC