C#: easiest way to populate a ListBox from a List

If I have a list of strings, eg:

List<string> MyList = new List<string>();
MyList.Add("HELLO");
MyList.Add("WORLD");

Is there an easy way to populate a ListBox using the contents of MyList?

Answers


Try

        List<string> MyList = new List<string>();
        MyList.Add("HELLO");
        MyList.Add("WORLD");

        listBox1.DataSource = MyList;

Have a look at ListControl.DataSource Property


Need Your Help

How can I use IMAP commands in VB.net to get response from Gmail.com server?

vb.net email imap

I'm using Visual Basic 2010 professional edition and I'm working on a software that part of it is to get the [Inbox] E-mails, but I can not even get a response from the server.

Python ValueError: Substring not found

python a-star

I have been working on this code and I have tried to debug it for almost a day by now, but I can't seen to find where the problem lies.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.