private void dgvCustomerlist_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { int index = e.RowIndex; DataGridViewRow selectedrow = dgvCustomerlist.Rows[index]; String IID = selectedrow.Cells[0].Value.ToString(); string name = selectedrow.Cells[1].Value.ToString(); string telephone = selectedrow.Cells[2].Value.ToString(); string address = selectedrow.Cells[3].Value.ToString(); string credit = selectedrow.Cells[4].Value.ToString(); frmAddCustomer frmaddc = new frmAddCustomer(IID, name, telephone, address, credit); frmaddc.ShowDialog(); } catch (ArgumentOutOfRangeException) { } catch (IndexOutOfRangeException sex) { } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void cmbCustomerSelect_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Enter) { if (dgvCustomerlist.RowCount == 1) { int index = 0; DataGridViewRow selectedrow = dgvCustomerlist.Rows[index]; String IID = selectedrow.Cells[0].Value.ToString(); string name = selectedrow.Cells[1].Value.ToString(); string telephone = selectedrow.Cells[2].Value.ToString(); string address = selectedrow.Cells[3].Value.ToString(); string credit = selectedrow.Cells[4].Value.ToString(); frmAddCustomer frmaddc = new frmAddCustomer(IID, name, telephone, address, credit); frmaddc.ShowDialog(); } } }
private void btnAddCustomer_Click(object sender, EventArgs e) { frmAddCustomer frmaddc = new frmAddCustomer(); frmaddc.ShowDialog(); }