Well, it depends on what you want to achieve from the selected list item.
There are several possible ways, let me try to explain some of them for your homework.
Suppose you have a data table with two columns and their rows ...
ID Title _________________________ 1 First item title 2 Second item title 3 Third item title
And you bind this data table to your list as
ListBox1.DisplayMember = "ID"; ListBox1.ValueMember = "Title";
If the user selects the second item from the list.
Now, if you want to get the displayed value (Title) of the selected item, you can do
string displayValue = ListBox1.Text;
OR even to get the same results.
And to get an element of value against the selected element, you need to do
string selectedValue = ListBox1.SelectedValue;
Now there are situations when you want to allow the user to select more than one item from the list, so you set
ListBox1.SelectionMode = SelectionMode.MultiSimple;
OR
ListBox1.SelectionMode = SelectionMode.MultiExtended;
Now suppose the user selects two items; second and third.
This way you can get the display values ββjust by going through SelectedItems
string displayValues = string.Empty; foreach (object selection in ListBox1.SelectedItems) { displayValues += selection.ToString() + ","; }
And if you want to get ID's instead of Title's , then ...
I also look through it, I will send if I find it.
Hope your understanding is built.
Good luck