I am having trouble getting three different group boxes with check boxes to bring back the data into a data grid. i need it to get all the items checked and bring back the data in the window.
What i have so far work one at a time but it will not give me all three only the last checked. i have done this for the three group boxes Carriers, Priority and Cooler
private void CheckBox(object sender, RoutedEventArgs e)
{
var child = new GroupBox();
List currentlyCheckedCheckBox = new List();
List currentlyUnCheckedCheckBox = new List();
foreach (var child in cbCarriers.Children)
{
if (child.GetType() == typeof(CheckBox))
{
Checking for IsChecked
CheckBox currentCheckBox = (CheckBox)child;
if ((bool)currentCheckBox.IsChecked)
{
currentlyCheckedCheckBox.Add(currentCheckBox.Content.ToString());
}
else
{
currentlyUnCheckedCheckBox.Add(currentCheckBox.Content.ToString());
}
if ((bool)currentCheckBox.IsChecked == false)
{
return myMain.dtOrders;
}
}
}
if (currentlyCheckedCheckBox.Count == 0)
{
currentlyCheckedCheckBox = currentlyUnCheckedCheckBox;
}
List checkedOrders = new List();
foreach (var item in db.Orders)
{
foreach (var checkboxName in currentlyCheckedCheckBox)
{
if (item.ShipVia.Trim() == checkboxName)
{
checkedOrders.Add(item);
}
}
}
grdOrders.ItemsSource = checkedOrders;
}
Goran KozarPosted Jul 16, 2015, 12:12 PM
Vilas ShendePosted Jul 14, 2015, 5:09 AM