Reputation: 129
I have five textbox and a button in Form1 and than I want to send values textbox to datagridview in Form2. when trying to run it will display the error message "does not contain a constructor that takes 5 arguments " this code for Form1 :
private void button2_Click(object sender, EventArgs e)
{
string IdStudent = textBox1.Text;
string NameStudent = textBox2.Text;
string AddressStudent = textBox3.Text;
string EmailStudent = textBox4.Text;
string PhoneNumStudent = textBox5.Text;
Form2 frm = new Form2(IdStudent,NameStudent,AddressStudent,EmailStudent,PhoneNumStudent);
this.Close();
And this code form2 :
public partial class Form2 : Form
{
public Form2(String User, string IdStudent, string NameStudent, string AddressStudent, string EmailStudent, string PhoneNumStudent)
{
InitializeComponent();
int row = 0;
dataGridView1.Rows.Add();
row = dataGridView1.Rows.Count - 2;
dataGridView1["IdStudent", row].Value = IdStudent;
dataGridView1["NameStudent", row].Value = NameStudent;
dataGridView1["AddressStudent", row].Value = AddressStudent;
dataGridView1["Email", row].Value = EmailStudent;
dataGridView1["Phone", row].Value = PhoneNumStudent;
dataGridView1.Refresh();
there anything you can provide feedback or solution?
Upvotes: 0
Views: 1141
Reputation: 129
thanks for your feedback and give solution. but I have found the solution of my problems at the following links : this
Upvotes: 1
Reputation: 257
i can't send comment,
remove "String User" from Form2 cunstroctor parameters or send it from form1
Upvotes: 1