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");
}

share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor