Please tell me how can I get ValueMember
of ListBox
SelectedItems
? I have read many tutorials but still I am unable to solve it. Any help will be greatly appreciated.
int c = subjects_Listbox.Items.Count - 1;
for (int i = 0; i >= 0; i--)
{
if (subjects_Listbox.GetSelected(i))
{
txt.Text += subjects_Listbox.SelectedIndices[i].ToString();
txt.Text += ", ";
}
}
Your
for
loop is incorrect. Just try this (this iterate through allSelectedIndices
of yourListBox
and will add them to yourTextBox
):Or even better: