Getting all the checked checkboxes within a DataGridCheckBoxColumn

Jan 27, 2009 at 1:18 PM

I have created a DatagridCheckBoxColumn dynamically in C#. How do I get all checked checkbox indexes saved to an array?

The DataGridCheckBoxColumn is created as follows..

DataTable dtHS = new DataTable();
dtHS.Columns.Add("Units (" + sUnits + ")", typeof(string));
dtHS.Columns.Add("Set HS", typeof(bool));

 for (int i = 1; i <= 10; i++ )
          dtHS.Rows.Add(i, false);

dgHydSt.ItemsSource = dtHS.DefaultView;

Thanks in advance.
Jan 27, 2009 at 10:51 PM
A checkbox (or any other control) is just a representation of the data behind. Iterate through you data source (ItemsSource), check the field which is bound the CheckBoxColumn and you get your items (indices)..