I have listbox1 - its datasource is a column (productname).
so i have in the listbox a MultiSelection
option.
and im trying to make a MessageBox
for all the option i selected and this the code:
foreach (object selectedItem in listBox1.SelectedItems)
{
MessageBox.Show((selectedItem.ToString() + Environment.NewLine));
}
the problem is that im getting this value insteadSystem.Data.DataRowView
How do you populate the listbox (ie what is exactly the datasource)?
From your comment I would say a DataView (and wich contains DataRowView...)
So you just need to cast the
SelectedItem
intoDataRowView
in order to get a value from this DataRowView:The VB.Net developers that could fall on this post could also be interested in this.
Try to change with this