Shivendra Shivendra - 1 year ago 95 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"/>

Answer Source

try this :

foreach(var child in Checksum_Collection.Children)
    if(child.getType() == typeof(CheckBox))
            MsgBox ("CheckboxName");    // or do whatever u want
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download