Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

How To Iterate List All Selected Items In A Databound Listbox In Net 4 0 Winforms

- 07 May 2010

A seemingly easy thing to do that I could not find documentation for!

string astr;
foreach (DataRowView aRow in listBox1.SelectedItems )
{
    astr = aRow[“TopicId”].ToString();
    astr = aRow[“TopicText”].ToString();
}

TopicId and TopicText are the name of the columns in the table of the Datasource that has been bound to the listbox control.

Drop me a note if you found this useful!

<< Go Back