C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// добавить 1 элемент
listBox1.Items.Add("aaa");
// добавить много элементов
string[] arr = { "bbb", "ccc", "ddd", "eee" };
listBox1.Items.AddRange(arr);
// удалить элемент по индексу
listBox1.Items.RemoveAt(3); // удалим "ddd"
// удалить элемент по значению
listBox1.Items.Remove("eee");
// получить каждый элемент из ListBox
for (int i=0;i<listBox1.Items.Count;i++)
{
string str = listBox1.Items[i].ToString();
}
}
}
}
Компилируем и запускаем. Все работает!