Shivendra Shivendra - 2 months ago 7x Question

how to check if any checkbox is checked in grid,wpf

I have number of checkboxs in grid,i have to check if any check box is checked then it will print name like- MsgBox ("CheckboxName").

<Grid Height="179" Width="290" Name="Checksum_Collection" >
<CheckBox Content="Alder32" Height="20" Name="Alder32CheckBox" />
<CheckBox Content="BsdChecksum" Height="20" Name="BsdChecksumCheckBox"/>
<CheckBox Content="CRC16" Height="20" Name="CRC16CheckBox"/>
<CheckBox Content="Damm" Height="20" Name="DammCheckBox"/>
<CheckBox Content="Fletcher" Height="20" Name="FletcherCheckBox" />
<CheckBox Content="LRC" Height="20" Name="LRCCheckBox" />
<CheckBox Content="Luhn" Height="20" Name="LuhnCheckBox"/>
<CheckBox Content="MD5 Hash" Height="20" Name="MD5CheckBox"/>


try this :

foreach(var child in Checksum_Collection.Children)
    if(child.getType() == typeof(CheckBox))
            MsgBox ("CheckboxName");    // or do whatever u want