How to detect if items are added to a ListBox (or CheckedListBox) control

前端 未结 4 1486
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 16:38

This seems like a fundamentally simple question. I have a WinForms dialog box with a listbox. This control is not populated via data-binding but is filled with call

4条回答
  •  失恋的感觉
    2020-12-09 17:05

    Unfortunately, there's no easy way to do this using inheritance or events. You should be able to override the Add method of the Items class, but you can't get to it! You may be able to intercept the message loop to figure out when this is happening, but that's beyond my experience.

    One thing I noticed from your question is that you mention items are being added asynchronously. Don't do that. Your problem may be solved if you synchronize on the form's thread (if your problem is that the control isn't updating).

提交回复
热议问题