private void dgvScheduler_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { try { DataTable dsDataTable = new DataTable(); dsDataTable = queryManager.SelectAllFromTBScheduler(); DialogResult dialogResult = MessageBox.Show("Do you want to delete row from Data Table and Grid.", "", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { string Id = dgvScheduler.SelectedRows[0].Cells[0].Value.ToString(); queryManager.DeleteSelectedRowFromTBScheduler(Id); try { btnstartScheduler.Invoke(new MethodInvoker(delegate { btnstartScheduler.Enabled = true; })); } catch { } } else { e.Cancel = true; } } catch { } //MessageBox.Show("Selected row is successfully deleted."); }
public void LoadDataGrid() { try { dgvScheduler.Invoke(new MethodInvoker(delegate { dgvScheduler.DataSource = queryManager.SelectAllFromTBScheduler(); })); } catch { } }