I have an empty DataGrid in a WPF interface. This DataGrid is automatically populated with the results of an SQL query and converts the Boolean values into the CheckBox within the DataGrid. How can I access these CheckBox from C# to capture when their status changes?
private static void RefreshPaths(DataGrid dataGridPaths, string connectionString) {
string commandText = "SELECT * FROM dbo.Paths";
using (SqlConnection connection = new SqlConnection(connectionString)) {
SqlCommand command = new SqlCommand(commandText, connection);
try {
connection.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandText, connection);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
dataGridPaths.ItemsSource = dt.DefaultView; // DataGrid REFILL HERE
connection.Close();
dataAdapter.Dispose();
connection.Dispose();
} catch (Exception ex) {
MessageBox.Show(ex.Message);
connection.Close();
connection.Dispose();
}
}
Aucun commentaire:
Enregistrer un commentaire