.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> WPF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Create CheckBoxList in ComboBox

Posted By:Syed Shakeer Hussain       Posted Date: January 05, 2011    Points: 75    Category: WPF    URL: http://www.dotnetspark.com  

The Below Artilce show you how to crate a CheckBoxList in ComboBox.The user can can select Multiple Items from a CheckBoxlist.The CheckBoxList stores 'The Text' as follows.
 

 


Creating  CheckBox List in .XMl code

                Width="100" Height="22">
     ItemsSource="{Binding TheList}"
                Height="145" >

    
        
                                 IsChecked="{Binding IsSelected}"
                   Content="{Binding TheText}"/>
          

     

 
 


Adding Items in .XML.CS code
public ObservableCollection TheList { get; set; }

public class BoolStringClass
 {
            public string TheText { get; set; }
            public bool IsSelected { get; set; }
   }

Write the below code  in FormLoad or Button Click event :

             ComboBoxDistributorGlb.SelectedIndex = 0;
            TheList = new ObservableCollection();
            TheList.Add(new BoolStringClass { IsSelected = true, TheText = "Some text for item #1" });
            TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #2" });
            TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #3" });
            TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #4" });
            this.DataContext = this;

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend