private void addItem_Click(object sender, EventArgs e) { AddForm addForm = new AddForm(Location); addForm.ShowDialog(); if (addForm.ReturnValues != null) { if (tabControl.SelectedIndex == addForm.createTypeComboBox.SelectedIndex) { dataGridView.Rows.Add(addForm.ReturnValues); refreshButton_Click(this, EventArgs.Empty); } UpdateData(); } }
private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } object data = null; switch (tabControl.SelectedIndex) { case 0: data = _projectList.Find(search => search.Id == int.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString())); break; case 1: data = _employeeList.Find(search => search.Id == int.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString())); break; case 2: data = _customerList.Find(search => search.Id == int.Parse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString())); break; } AddForm addForm = new AddForm(new Point(Cursor.Position.X - 100, Cursor.Position.Y - 50), true, tabControl.SelectedIndex, data); addForm.ShowDialog(); if (addForm.ReturnValues != null) { dataGridView.Rows[e.RowIndex].SetValues(addForm.ReturnValues); refreshButton_Click(this, EventArgs.Empty); UpdateData(); } }