2010-02-06 66 views
1

如何在列表框内添加复选框。 ChechBoxList控件不适用于更多记录,通过使用listbox用户可以轻松滚动选择该项目。列表框内的复选框

Geetha。

回答

2

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> 

要访问用户的行动项目

void checkboxlist1_Clicked(Object sender, EventArgs e) 
{   
    if (checkBoxList1.SelectedIndex == 1) 
    { 
     // DoSomething 
    }  
} 
+0

这是CheckBoxList,而不是checkedListBox。 – 2010-02-06 08:12:36

-1
<ListBox x:Name="targetList" ItemsSource="{Binding}"> 

<ListBox.ItemTemplate> 

<HierarchicalDataTemplate> 

<StackPanel Orientation="Horizontal"> 

<CheckBox> 

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

</CheckBox> 

</StackPanel> 

</HierarchicalDataTemplate> 

</ListBox.ItemTemplate> 

</ListBox> 
+0

原始海报(OP)询问ASP.NET解决方案 - 请阅读该问题。 – 2010-02-06 07:30:21