private void dgvCustom_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { //回车时,DataGridView会自动向下一行,这里向上取一行,就可以取当前行了 if (dgvCustom.CurrentRow.Index != dgvCustom.Rows.Count - 1) { dgvCustom.CurrentCell = dgvCustom.Rows[dgvCustom.CurrentRow.Index - 1].Cells[cust_code.Name]; } strCustomerNo = dgvCustom.CurrentRow.Cells["cust_code"].Value.ToString(); strCustomerName = dgvCustom.CurrentRow.Cells["cust_name"].Value.ToString(); strCustomerId = dgvCustom.CurrentRow.Cells["cust_id"].Value.ToString(); strLegalPerson = dgvCustom.CurrentRow.Cells["cont_name"].Value.ToString(); CustomerInfo = new CustomerInfo(strCustomerId); this.DialogResult = DialogResult.OK; } }
private void dgvCustom_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { strCustomerNo = dgvCustom.Rows[e.RowIndex].Cells["cust_code"].Value.ToString(); strCustomerName = dgvCustom.Rows[e.RowIndex].Cells["cust_name"].Value.ToString(); strCustomerId = dgvCustom.Rows[e.RowIndex].Cells["cust_id"].Value.ToString(); strLegalPerson = dgvCustom.Rows[e.RowIndex].Cells["cont_name"].Value.ToString(); CustomerInfo = new CustomerInfo(strCustomerId); this.DialogResult = DialogResult.OK; } }
private void btnSubmit_Click(object sender, EventArgs e) { if (!IsCheck()) { return; } strCustomerNo = dgvCustom.CurrentRow.Cells["cust_code"].Value.ToString(); strCustomerName = dgvCustom.CurrentRow.Cells["cust_name"].Value.ToString(); strCustomerId = dgvCustom.CurrentRow.Cells["cust_id"].Value.ToString(); strLegalPerson = dgvCustom.CurrentRow.Cells["cont_name"].Value.ToString(); CustomerInfo = new CustomerInfo(strCustomerId); this.DialogResult = DialogResult.OK; }
private void dgvCustom_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { strCustomerNo = dgvCustom.CurrentRow.Cells["cust_code"].Value.ToString(); strCustomerName = dgvCustom.CurrentRow.Cells["cust_name"].Value.ToString(); strCustomerId = dgvCustom.CurrentRow.Cells["cust_id"].Value.ToString(); strLegalPerson = dgvCustom.CurrentRow.Cells["cont_name"].Value.ToString(); CustomerInfo = new CustomerInfo(strCustomerId); this.DialogResult = DialogResult.OK; } }