Getting value of selected item in list box as string
string textValue = ((ListBoxItem)listBox1.SelectedItem).Content.ToString();
To retreive the value of all selected item in à listbox you can cast selected item in DataRowView and then select column where your data is:
foreach(object element in listbox.SelectedItems) {
DataRowView row = (DataRowView)element;
MessageBox.Show(row[0]);
}
If you are using ListBox in your application and you want to return the selected value of ListBox and display it in a Label or any thing else then use this code, it will help you
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
label1.Text = listBox1.SelectedItem.ToString();
}
If you want to retrieve the display text of the item, use the GetItemText
method:
string text = listBox1.GetItemText(listBox1.SelectedItem);