如何从WinForm中的Gridview获取Populate组合框值?

时间:2017-06-03 21:29:13

标签: c# winforms gridview combobox

我想在StudentRegistrationForm中获取网格视图数据。我已经尝试了很多次,但我无法做到这一点,我不明白。你能告诉我如何在StudentRegistrationForm中获取GridView值吗?

如果我评论组合框代码,则其他值会放在StudentRegistrationForm中,但我想在StudentRegistrationForm中显示所有数据。

enter image description here

St_Registration obj = new St_Registration();
int St_Id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
obj.txt_name.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
obj.txt_fname.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
obj.txt_sur_name.Text =dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
obj.txt_email.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
obj.dob_date.Text = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
obj.date_of_registration.Text=dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
obj.txt_address.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
obj.rbtn_male.Checked = true;
obj.rbtn_female.Checked = false;

if (dataGridView1.Rows[e.RowIndex].Cells[8].Value.ToString() == "Female")
{
    obj.rbtn_male.Checked = false;
    obj.rbtn_female.Checked = true;
}
obj.txt_contact.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString();
obj.cmb_country.Text=dataGridView1.Rows[e.RowIndex].Cells[10].Value.ToString();
obj.cmb_province.Text = dataGridView1.Rows[e.RowIndex].Cells[11].Value.ToString();
obj.cmb_city.Text = dataGridView1.Rows[e.RowIndex].Cells[12].Value.ToString();
obj.txt_pin.Text=dataGridView1.Rows[e.RowIndex].Cells[13].Value.ToString();
obj.ShowDialog();

0 个答案:

没有答案