private void dgvInhosList_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { //获取行信息 if (e.RowIndex < this.dgvInhosList.Rows.Count) { DataGridViewRow row = this.dgvInhosList.Rows[e.RowIndex]; this.pid = row.Cells[this.dgvInhosList.Columns["id"].Index].Value.ToString(); //主信息id 传入到修改窗口 Form detailForm = new ModifyInfo(this.pid); detailForm.ShowDialog(this); } }
private void btnSearchDetail_Click(object sender, EventArgs e) { //判断选中几行 try { int count = 0; for (int i = 0; i < this.dgvInhosList.Rows.Count; i++) { if (this.dgvInhosList.Rows[i].Cells[this.dgvInhosList.Columns["SelectCheck"].Index].EditedFormattedValue.ToString() == "True") { count++; if (count > 1) { MessageBox.Show("请选择一行要查询的记录!"); return; } this.pid = this.dgvInhosList.Rows[i].Cells[this.dgvInhosList.Columns["id"].Index].Value.ToString(); //主信息id 传入到修改窗口 Form detailForm = new ModifyInfo(this.pid); detailForm.ShowDialog(this); return; } } if (count == 0) { MessageBox.Show("请选择要查询的记录!"); return; } } catch (Exception ex) { throw ex; } }