private void CheckBox_Click_1(object sender, RoutedEventArgs e) { try { if (crimesDataGrid.SelectedItem != null) { Crime c; c = crimesDataGrid.SelectedItem as Crime; if ((sender as CheckBox).IsChecked.Value) { sqlWorker.executeQuery("UPDATE Crime SET isRegistred = 1 WHERE idCrime = " + c.Id); c.IsRegistred = true; } else { sqlWorker.executeQuery("UPDATE Crime SET isRegistred = 0 WHERE idCrime = " + c.Id); c.IsRegistred = false; } coll.View.Refresh(); } } catch { } }