简体   繁体   中英

When I set the ListBox SelectionMode to “None”, it doesn't react to DataSource changes

while searching for an answer, I found out it's an old "bug" in VS !(?) I am using VS2013. I simply don't believe that they didn't correct it, so I have to think it's intentional, or there's something I am not doing right...

I want to use ListBox to dislpay some simple results. I want that list to be read-only, items not selectable and so on. Just a display of a simple array of results.

I use an array as a datasource (lstBox.DataSource = somearray;), which I update by setting DataSource to null, then back to somearray. The problem is - if I set the listBox SelectionMode to "none", list gets stuck and it doesn't refresh anymore. I can't refresh it. If I set list as "disabled" instead, it's showing the results correctly, it's not selectable, no matter what SelectionMode says, but it's all greyed out... Any help on this ?

ps from what I've read, even setting datasource to BindingList or BindingSource doesn't rectify this problem...

SelectionMode does not have a None value in WPF. (although it had in WinForms )

In WPF, if you want to present items without allowing selection, you should use the ItemsControl class instead of the ListBox .

But I'm not sure whether you are using WPF or WinForms by reading your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM