ListBox.Items - ObjectCollection . This means that you can select the type of object to enter.
When you do this:
string title = drv["title"].ToString(); listBox1.Items.Add(title);
you put string objects in it, so you will need to output them like this:
foreach (string item in listBox1.Items)
Instead, you probably want your code to be something like this:
ListViewItem item = new ListViewItem(title); item.Tag = tag; tag.photoid = (int)drv["photoid"]; listBox1.Items.Add(item); // The difference is here - add *item* not *title*
then you can use it the way you wrote it at the beginning:
foreach (ListViewItem item in listBox1.Items)
Jeffh source share