Getting a value from another form
-
Hi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
-
Hi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
Either make the textbox in form 1 public, or define a property or function that's public to return the entered text. Then in form 2, you will be able to access it via the form 1 object. If you do not have a reference to the form 1 object in form 2, you won't be able to do that though.
- Dy
-
Hi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
-
Hi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
Hello Let me help you about this public problem. 1.in Form1 go to code view page (press F7) 2.change below definition of textBox1:
**private** System.Windows.Forms.TextBox textBox1;
To :**public** static System.Windows.Forms.TextBox textBox1;
3.now if you build your project you got some errors as : ...cannot be accessed with an instance reference; ... and you should change all "this.textBox1" to "Form1.textBox1" like :**this**.textBox1 = new System.Windows.Forms.TextBox();
change to :**Form1**.textBox1 = new System.Windows.Forms.TextBox();
3.go to Form2 and where you want to access Form1's textBox1 just use this :MessageBox.Show (**Form1.textBox1.Text**);
Easy... mail me if you have problem yet :-D -- modified at 11:14 Monday 8th May, 2006 -
Hi all, I have a textbox in Form1, where the user of the mentioned program is going to enter his name. Then I have another Form (Form2) in which I would like to display the name of the user by getting it from Form1. I am using MDI. Can I do it? If so, can you help me please! Thanks a lot for your help
-
Hello Let me help you about this public problem. 1.in Form1 go to code view page (press F7) 2.change below definition of textBox1:
**private** System.Windows.Forms.TextBox textBox1;
To :**public** static System.Windows.Forms.TextBox textBox1;
3.now if you build your project you got some errors as : ...cannot be accessed with an instance reference; ... and you should change all "this.textBox1" to "Form1.textBox1" like :**this**.textBox1 = new System.Windows.Forms.TextBox();
change to :**Form1**.textBox1 = new System.Windows.Forms.TextBox();
3.go to Form2 and where you want to access Form1's textBox1 just use this :MessageBox.Show (**Form1.textBox1.Text**);
Easy... mail me if you have problem yet :-D -- modified at 11:14 Monday 8th May, 2006freshonlineMax wrote:
change below definition of textBox1: private System.Windows.Forms.TextBox textBox1; To : public static System.Windows.Forms.TextBox textBox1;
:omg: Why make fields in a class private, why not make them public?[^]
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog
-
:-> Thanks for plugging my article :-D
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog