datagridview 数据处理方法 修改 删除 添加 下拉类表 弹出窗口
string id = dgv.Rows[e.RowIndex].Cells[0].Value.ToString();
string user_id = dgv.Rows[e.RowIndex].Cells[1].Value.ToString(); string user_password=
dgv.Rows[e.RowIndex].Cells[2].Value.ToString();
string user_class = dgv.Rows[e.RowIndex].Cells[3].Value.ToString(); string user_name = dgv.Rows[e.RowIndex].Cells[4].Value.ToString(); string user_sex = dgv.Rows[e.RowIndex].Cells[5].Value.ToString(); string outUserid,
outUserpassword,outUserclass,outUsername,outUsersex;
DialogResult myresult;
this.ShowDialogForm(id, user_id, user_password, user_class, user_name, user_sex,
out outUserid, out outUserpassword, out outUserclass, out outUsername, out outUsersex, out myresult);
if (myresult==DialogResult.OK)
{
dgv.Rows[e.RowIndex].Cells[1].Value = outUserid;
dgv.Rows[e.RowIndex].Cells[2].Value = outUserpassword;
dgv.Rows[e.RowIndex].Cells[3].Value = outUserclass;
dgv.Rows[e.RowIndex].Cells[4].Value = outUsername;
dgv.Rows[e.RowIndex].Cells[5].Value = outUsersex;
}
}
}
}
private void ShowDialogForm(string id, string user_id, string user_password, string user_class, string user_name, string user_sex,
out string outUserid, out string outUserpassword, out string outUserclass, out string outUsername, out string outUsersex, out DialogResult myresult)
{
dialog2 frm = new dialog2();
//读取输入参数,显示在子窗口中
frm.Controls["ID_TB"].Text = id;
frm.Controls["USER_ID_TB"].Text = user_id;
frm.Controls["USER_PWD_TB"].Text = user_password;
frm.Controls["USER_CLASS_TB"].Text = user_class;
// ER_CLASS_CB.SelectedValue = 2;