Get selectedvalues of multi-select list box

前端 未结 6 1161
[愿得一人]
[愿得一人] 2021-01-16 10:05

I have got a list box in multi select mode which is data bound with 15 values from a database. I have this code to display the selected values of each item selected in the l

6条回答
  •  囚心锁ツ
    2021-01-16 10:49

    I think you may have a logic error in your code. You are looping through the SelectedItems, but your MessageBox is still using the list_box to display a value. How about this?

    foreach (var list in list_box.SelectedItems)         
    {                          
    MessageBox.Show(list.ToString());         
    } 
    

提交回复
热议问题