jeudi 8 mars 2018

Check all CheckBoxes inside a ListBox in a loop c#

I have the following Code:

<ListBox Name="lstCheckBoxes" Grid.Row="4" Grid.RowSpan="5" Grid.Column="1" Grid.ColumnSpan="5">
        <CheckBox Name="CheckboxKlimaanlage" Content="Klimaanlage"/>
        <CheckBox Name="CheckboxSensor" Content="Sensor"/>
        <CheckBox Name="CheckboxDigital"  Content="Digital"/>
        <CheckBox Name="CheckboxAnalog"  Content="Analog"/>
        <CheckBox Name="CheckboxAndere1"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere2"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere3"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere4"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere5"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere6"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere7"  Content="Anderes"/>
        <CheckBox Name="CheckboxAndere8"  Content="Anderes"/>
    </ListBox>

and the following Problem: I want to check every Checkbox inside the ListBox with a loop and save the content from the active boxes in something like a list.

I already saw some code like .. foreach (Control c in panel1.Controls).. but the .Controls wont work.




Aucun commentaire:

Enregistrer un commentaire