I want to sent data from one class to other using method.
e.x.
This is form1
namespace sof
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Form2 f2 = new Form2();
private void Form1_Load(object sender, EventArgs e)
{
f2.Show();
}
public void data(string name,bool re)
{
label1.Text = name;
if (re == true)
label1.BackColor = Color.Lime;
else
label1.BackColor = Color.Red;
}
}
This is Form2
namespace sof
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
Form1 f1 = new Form1();
private void button1_Click(object sender, EventArgs e)
{
f1.data("Alex",true);
}
}
}
Now I want from Form2 sent this data(f1.data("Alex",true);) back to Form1 and set label1 tex.
Thanks in advance for your help