private void btnAddTruck_Click(object sender, EventArgs e) { AddEditTruck dialog = new AddEditTruck(); if (dialog.ShowAdd() != DialogResult.Cancel) { refresh(); } }
private void btnEditSelected_Click(object sender, EventArgs e) { AddEditTruck dialog = new AddEditTruck(); DataGridViewRow row = null; if (dataGridTrucks.SelectedRows.Count > 0) { row = dataGridTrucks.SelectedRows[0]; TruckEntity doc = (TruckEntity)row.DataBoundItem; if (dialog.ShowEdit(doc) != DialogResult.Cancel) { refresh(); } } else { MessageBox.Show("Please select a row to edit."); } }