I need basically something like this :
SqlCommand selectTags = new SqlCommand("select tag from Categories", cs);
SqlDataAdapter da = new SqlDataAdapter(selectTags);
DataTable dt = new DataTable();
cs.Open();
da.Fill(dt);
cs.Close();
CheckBox chkbb = new CheckBox();
list1.content
foreach (DataRow dr in dt.Rows)
{
MessageBox.Show(dr["tag"].ToString());
Checkbox chk = new Checkbox into list1(list view) (This line supposed to be example. not working code. )
chk.Content = dr["tag"].ToString();
}
Is it possible to create dynamical checkboxes depended on rows in sql database?
It can be added on page load etc.. I have no idea how to make something like this. Thank you so much for any help given.
added xaml of checkboxes
<ListView Name="list1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="307,52,0,0" Height="132" Width="293">
<CheckBox Content="inf" Visibility="Visible" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="chkBoxInfo" Width="43"/>
<CheckBox Content="spo" Visibility="Visible" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="chkBoxSp"/>
<CheckBox Content="war" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="chkBoxWar"/>
<CheckBox Content="cul" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="chkBoxCul" Height="14" Width="39"/>
</ListView>
Aucun commentaire:
Enregistrer un commentaire