Introduction:
Hi Guys! In this tutorial we learn how to pass data from one
form to other form in windows form application using c#.
Let’s Follow the Step and create windows form application.
Step1:
Visual studio-àFile-àNew-àProject àwindows Form
Application-àOk
Step2:
Click on ToolBox-à
Drag and drop Label and TextBox. I creat a Form with 3 Labels and TextBox as
shown in fig.
Step 3:
I have Name,Fname,Address Label on Form .so I take a three
global variable .Write this code on the Form1.cs
public static string SetValueForText1 = "";
public static string SetValueForText2 = "";
public static string SetValueForText3 = "";
Step4:
Project-àAdd Windows Form-àClick
on Add
Step 5:
After Creating Form Double Click on Submit button on windows
Form1 and Write the Code:
private void button1_Click(object sender, EventArgs e)
{
SetValueForText1 = textBox1.Text;
SetValueForText2 = textBox2.Text;
SetValueForText3 = textBox3.Text;
Form2 frm2 = new Form2();
frm2.Show();
}
Step 6:
Drag and Drop 3 Label from Toolbox on Form2.
Step 7:
Double Click on Form2 and write the Code:
private void Form2_Load(object sender, EventArgs e)
{
label1.Text = Form1.SetValueForText1;
label2.Text = Form1.SetValueForText2;
label3.Text = Form1.SetValueForText3;
}
Step 8:
Now Press F5 to Run the Application
Fill the Form1 and click on Submit. Data will pass From
Form1 to Form 2.
Passing TextBox's text to another browse windows application with Auth is possible? I will pay for it
ReplyDelete