SIGN UP MEMBER LOGIN:    
ARTICLE

Adding Items to a ListBox

Posted by Mahesh Chand Articles | Windows Forms C# March 06, 2001
Sample code shows you how to add items to a list box.
Reader Level:

Ok, adding items to a listbox control is easy. You use Add method of the control. The following code shows you how to do so.

Drag a ListBox control on a form and use the following code to add items to the control.

Source Code:

private void Form1_Load(object sender, System.EventArgs e)
{
string str = "First item";
int i = 23;
float flt = 34.98f;
listBox1.Items.Add(str);
listBox1.Items.Add(i.ToString());
listBox1.Items.Add(flt.ToString());
listBox1.Items.Add("Last Item in the List Box");
}

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor