CheckBox inside ListBox

2019-01-20 19:56发布

How to add checkbox inside the listbox. Where ChechBoxList controls is not good for more records, By using listbox user can easily scroll to choose the item.

Geetha.

3条回答
ゆ 、 Hurt°
2楼-- · 2019-01-20 20:25

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  
   }      
}
查看更多
仙女界的扛把子
3楼-- · 2019-01-20 20:27
<ListBox x:Name="targetList" ItemsSource="{Binding}">

<ListBox.ItemTemplate>

<HierarchicalDataTemplate>

<StackPanel Orientation="Horizontal">

<CheckBox>

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

</CheckBox>

</StackPanel>

</HierarchicalDataTemplate>

</ListBox.ItemTemplate>

</ListBox>
查看更多
放荡不羁爱自由
4楼-- · 2019-01-20 20:31

What you want is the

CheckBoxList.

Newer CheckBoxList

Pretty nice step-by-step here.

查看更多
登录 后发表回答