public static List<string> users=new List<string>();
...
ListBox1.DataSource = Class1.users;
I have a ListBox and I would like to fill it with values from a collection. I try this but the list just wont fill, what else do I need to do??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
After setting the data source, you need to bind the data:
If you do not set the
ListBox.DisplayMemberproperty, the binding will use your objectsToString()method for the item text. In your case, as you are using List, you do not need to setDisplayMember.