CheckBox inside ListBox

烈酒焚心 提交于 2019-11-28 14:45:37
Rob Cooper

What you want is the

CheckBoxList.

Newer CheckBoxList

Pretty nice step-by-step here.

Asad Butt

what about checkedListBox ?

<asp:CheckBoxList id="checkboxlist1" runat="server"> 
         <asp:ListItem>Item 1</asp:ListItem>
         <asp:ListItem>Item 2</asp:ListItem>  
         <asp:ListItem>Item 3</asp:ListItem>          
</asp:CheckBoxList>

To access items on user action

void checkboxlist1_Clicked(Object sender, EventArgs e) 
{          
   if (checkBoxList1.SelectedIndex == 1)
   {
       // DoSomething  
   }      
}
s3yfullah
<ListBox x:Name="targetList" ItemsSource="{Binding}">

<ListBox.ItemTemplate>

<HierarchicalDataTemplate>

<StackPanel Orientation="Horizontal">

<CheckBox>

<TextBlock Text="{Binding Path=Name}"/>

</CheckBox>

</StackPanel>

</HierarchicalDataTemplate>

</ListBox.ItemTemplate>

</ListBox>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!