C# 列表框内的复选框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2212390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:29:08 来源:igfitidea点击:
CheckBox inside ListBox
提问by Geeth
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.
如何在列表框内添加复选框。ChechBoxList 控件不适合记录更多的地方,通过使用列表框用户可以轻松滚动选择项目。
Geetha.
吉塔。
回答by Asad
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
}
}
回答by 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>