I\'m populating a ListBox in a WinForms application, this way:
listBoxUsers.DataSource = ctx.Users.ToList(); listBoxUsers.DisplayMember = \"Name\"; listBoxUsers.
try this:
foreach (DataRowView item in listBoxUsers.SelectedItems) { int id=int.parse(item[0].ToString()); }