Here
Form3 a = new Form3(firstNameTxtBox.Text);
you are calling the Form3
constructor with one argument.
As the error explains, Form3
does not contain a constructor that takes a single argument. This is why when you remove the second argument from the constructor the error goes away.
You have two options:
1) Remove the second constructor argument.
public Form3(string a)
{
InitializeComponent();
firstNameLbl.Text = a;
}
2) Add the second argument to all the places where you call the Form3
constructor.
If you need the second constructor argument I suggest option 2.
For example:
Form3 a = new Form3(firstNameTxtBox.Text, lastNametextBox.Text);
Your final Form1 code would look something like:
public Form1()
{
InitializeComponent();
}
private void nextBtn_Click(object sender, EventArgs e)
{
Form3 a = new Form3(firstNameTxtBox.Text, lastNametextBox.Text);
a.Show();
this.Hide();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…