Code -
Form 1 code -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Exp3
{
public partial class Form1 : Form
{
public static string SetValueForText1 = "";
public static string SetValueForText2 = "";
public static string SetValueForText3 = "";
public static string SetValueForText4 = "";
public static string SetValueForText5 = "";
public static string SetValueForText6 = "";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
SetValueForText1 = textBox1.Text;
SetValueForText2 = textBox2.Text;
SetValueForText3 = textBox3.Text;
SetValueForText4 = textBox4.Text;
SetValueForText5 = textBox5.Text;
SetValueForText6 = textBox6.Text;
Form2 frm2 = new Form2();
frm2.Show();
}
}
}
Form 2 code -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Exp3
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = Form1.SetValueForText1;
textBox2.Text = Form1.SetValueForText2;
textBox3.Text = Form1.SetValueForText3;
textBox4.Text = Form1.SetValueForText4;
textBox5.Text = Form1.SetValueForText5;
textBox6.Text = Form1.SetValueForText6;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
}
}
Output -
Form 1 Output –
Form 2 Output
(Details of Form1 displayed on Form2) –
0 Comments