// Create a ListBox control ListBox listBox1 = new ListBox(); // Add some items to the ListBox listBox1.Items.Add("Item 1"); listBox1.Items.Add("Item 2"); listBox1.Items.Add("Item 3"); // Modify an item in the ListBox listBox1.Items[1] = "New Item 2"; // Refresh the ListBox to update the display listBox1.Refresh();
// Create a ListBox control ListBox listBox1 = new ListBox(); // Add some items to the ListBox listBox1.Items.Add("Item 1"); listBox1.Items.Add("Item 2"); listBox1.Items.Add("Item 3"); // Remove an item from the ListBox listBox1.Items.Remove("Item 2"); // Refresh the ListBox to update the display listBox1.Refresh();This example creates a ListBox control, adds items to it, removes an item, and then refreshes the ListBox to update the display. Package Library: System.Windows.Forms.dll