Geeth
Geeth

Reputation: 5343

CheckBox inside ListBox

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.

Upvotes: 1

Views: 29547

Answers (3)

Rob Cooper
Rob Cooper

Reputation: 28867

What you want is the

CheckBoxList.

Newer CheckBoxList

Pretty nice step-by-step here.

Upvotes: 5

s3yfullah
s3yfullah

Reputation: 165

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

<ListBox.ItemTemplate>

<HierarchicalDataTemplate>

<StackPanel Orientation="Horizontal">

<CheckBox>

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

</CheckBox>

</StackPanel>

</HierarchicalDataTemplate>

</ListBox.ItemTemplate>

</ListBox>

Upvotes: -1

Asad
Asad

Reputation: 21928

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  
   }      
}

Upvotes: 2

Related Questions