private async void btnAdd_Click(object sender, EventArgs e) { AddFarm dialog = new AddFarm(); var result = await dialog.ShowForm(null); if (result != DialogResult.Cancel) { refresh(); } }
private async void btnEditSelected_Click(object sender, EventArgs e) { AddFarm dialog = new AddFarm(); DataGridViewRow row = null; if (dataGridFarms.SelectedRows.Count > 0) { row = dataGridFarms.SelectedRows[0]; FarmEntity doc = (FarmEntity)row.DataBoundItem; var result = await dialog.ShowForm(doc); if (result != DialogResult.Cancel) { refresh(); } } else { MessageBox.Show("Please select a row to edit."); } }