//I have this code
//In my Form1 I have textbox and a button
namespace Passing
{
public partial class Form1 : Form
{
Class1 class1 = new Class1();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
class1.Name = textBox1.Text;
Form2 form2 = new Form2();
form2.Show();
}
}
}
///I'm having a problem here --> Form2 form2 = new Form2();
///In my Form 2 I only have label1
namespace Passing
{
public partial class Form2 : Form
{
Class1 class1;
public Form2(Class1 class1)
{
class1.Name = label1.Text;
InitializeComponent();
this.class1 = class1;
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
//And in my class
namespace Passing
{
class Class1
{
string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
}
I'm having a hard time in here, since i;m new in c#. I want to input a text in my form1 and after clicking the button the text will be outputed on form2, label1.
Any help is appreciated. Thank you in advance :)))