我有一个程序,提示用户输入表单1的信息(firstName,lastName,phoneNumber,职业,性别)。单击提交按钮时,信息填写表单2上的datagridview。我可以让程序填充数据网格的第一行,但我无法让它允许保存用户的另一个条目。我已经在这一段时间了,任何帮助将不胜感激。我将包括我的按钮点击方法和我的表格1和2截图(我不能提供屏幕截图,直到我获得更高的代表),如果这将有所帮助。
提交按钮
private void submitButton_Click(object sender, EventArgs e)
{
if (this.firstNameTxtBox.Text == "")
{
MessageBox.Show("First Name is a required field: Please enter your First Name");
this.firstNameTxtBox.Focus();
return;
}
if (this.lastNameTxtBox.Text == "")
{
MessageBox.Show("Last Name is a required field: Please enter your Last Name");
this.lastNameTxtBox.Focus();
return;
}
if (this.occupationComboBox.Text == "--Select an occupation--")
{
MessageBox.Show("Occupation is a required field: Please select your occupation");
this.occupationComboBox.Focus();
return;
}
if (!maleRadioButton.Checked && !femaleRadioButton.Checked)
{
MessageBox.Show("Gender is a required field: Please select a Gender");
this.maleRadioButton.Focus();
return;
}
Data_Summary form2 = new Data_Summary();
form2.Show();
form2.summaryText.Rows.Add(firstNameTxtBox.Text, lastNameTxtBox.Text, phoneNumberTxtBox.Text, occupationComboBox.Text);
if (maleRadioButton.Checked)
{
form2.summaryText.Rows[0].Cells[4].Value = "Male";
}
if (femaleRadioButton.Checked)
{
form2.summaryText.Rows[0].Cells[4].Value = "Female";
}
}
addAnotherButton
private void addAnotherButton_Click(object sender, EventArgs e)
{
summaryText.Rows.Add();
}