private void editToolStripMenuItem_Click(object sender, EventArgs e) { //customer int rowIndex = customersDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (rowIndex > -1) { List <string> cellList = new List <string>(); for (int i = 0; i < customersDataGridView.Rows[rowIndex].Cells.Count; i++) { if (customersDataGridView.Rows[rowIndex].Cells[i].Value != null) { cellList.Add(customersDataGridView.Rows[rowIndex].Cells[i].Value.ToString()); } else { cellList.Add(string.Empty); } } int index = 0; if (int.TryParse(cellList[0], out index)) { foreach (var customer in (new CustomerController()).Customers) { if (customer.CustomerID == index) { EditCustomerData editCustomerData = new EditCustomerData(customer); editCustomerData.ShowDialog(); } } } } }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { //customer int rowIndex = customersDataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (rowIndex > -1) { List<string> cellList = new List<string>(); for (int i = 0; i < customersDataGridView.Rows[rowIndex].Cells.Count; i++) { if (customersDataGridView.Rows[rowIndex].Cells[i].Value != null) { cellList.Add(customersDataGridView.Rows[rowIndex].Cells[i].Value.ToString()); } else { cellList.Add(string.Empty); } } int index = 0; if (int.TryParse(cellList[0], out index)) { foreach (var customer in (new CustomerController()).Customers) { if (customer.CustomerID == index) { EditCustomerData editCustomerData = new EditCustomerData(customer); editCustomerData.ShowDialog(); } } } } }