Monday, April 21, 2014

ListBox Control with an Array of Strings


This example adds an array of strings to a ListBox control when the Windows Form opens.

Example  01:

private void Form1_Load(object sender, System.EventArgs e)
{
    string [] myList = new string[4];

    myList[0] = "One";
    myList[1] = "Two";
    myList[2] = "Three";
    myList[3] = "Four";

    listBox1.Items.AddRange(myList);
}

1 comment:

  1. How to bind list of multiple data type values like: StudenName (String), RollNumber (Numeric) and DateOfBirth (DateTime) as ABC S/O XYZ (1217, 2001-03-17)??

    ReplyDelete