Click here to Skip to main content
15,910,121 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Form1 have one textbox, and Form2 have also one textbox...
but when im enter any text in form1 textbox, then form2 textbox are autometicaly fill...
so how can i do this ?

Thanx in Advance...!!!! 
Posted
Updated 2-Jun-14 20:15pm
v2
Comments
Prasad Avunoori 3-Jun-14 2:18am    
Assign that value to a static field.
Harnis Findoliya 3-Jun-14 2:21am    
Thanx.. but how to assign static field...
Bh@gyesh 3-Jun-14 2:24am    
Create one object like objtextbox1 in form 2, assign it so when form2 is load, you can assign it to textbox resides in form2

Assign that value to static field and pass that value while calling form2
 
Share this answer
 
Static is one option
or you can make 2nd form textbox as public


then

form2 obj=new form2();
obj.textbox2.text=textbox1.text;

Try it ...
 
Share this answer
 
You can do it , by Modifying the access modifier of the Textbox to Public and you can assign the values to it by creating an instance of the second form
or by using a static variable.
 
Share this answer
 
Hi,

Please follow the below steps:

Create a static class
C#
static class Temp
{
   public static string textvalue;
}


get the text box value in form 1 and assign to the static variable of the static class

C#
private void button1_Click(object sender, EventArgs e)
       {
           Temp.textvalue = textBox1.Text;
       }


In the second form load get the static variable and assigned to the text box
C#
private void Form2_Load(object sender, EventArgs e)
       {
           textBox1.Text = Temp.textvalue;
       }


Hope this helps!

- S Francis
My Blog
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900