I have a weird issue where changing data grid column visibility with a press of a button, it triggers a "Checked" event tied to a checkbox in that data grid column.
So here's my setup:
-
I have a label (lblUpdateMode) with a text either "single row" or "every row";
-
A datagrid with 10 columns, where initially 5 columns are visible and 5 are hidden;
-
Pressing a button (btnChangeView) flips visibility of each column;
-
In one of the data grid columns I have a CheckBoxColumn, with Checked/Unchecked events. If label text = "every row" pressing on a single checkbox updates every row.
However, if label = "every row" and I press on btnChangeView, it also triggers Checked event and updates checkboxes in every row.
Why is this happening and how can I avoid it?
Here's the code to the Checked event - nothing fancy or strange:
private void UpdateDataGridCheckBox(string colname, bool v)
{
if (lblUpdateMode.Content.ToString() == "Every Row")
{
foreach (DataRow dr in DataAccess.Instance.sourceFiles.Rows)
{
dr[colname] = v;
}
}
}
Thanks
Aucun commentaire:
Enregistrer un commentaire