private void addOfficeButton_Click(object sender, EventArgs e) { using (var f = new EditOfficeForm()) { DataGridViewRow row = null; f.Saved += (s, eventArgs) => { if (row == null) { row = officesGridView.Rows[officesGridView.Rows.Add()]; } OfficesGridViewRenderRow(row, f.Office); f.Close(); }; f.ShowDialog(); } }
private void officesGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { int rowIndex = e.RowIndex, columnIndex = e.ColumnIndex; if (rowIndex >= 0 && columnIndex >= 0) { var row = officesGridView.Rows[rowIndex]; Office office = row.Tag as Office; using (var f = new EditOfficeForm(office.Id)) { f.Saved += (s, eventArgs) => { OfficesGridViewRenderRow(row, f.Office); f.Close(); }; f.ShowDialog(); } } }