How to retrieve selected values for selected items in a ListBox?

后端 未结 3 981
傲寒
傲寒 2021-01-25 07:23

I\'m populating a ListBox in a WinForms application, this way:

listBoxUsers.DataSource = ctx.Users.ToList();
listBoxUsers.DisplayMember = \"Name\";
listBoxUsers.         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-25 08:12

    try this:

    foreach (DataRowView item in listBoxUsers.SelectedItems)
                {
                  int id=int.parse(item[0].ToString());
                }
    

提交回复
热议问题