Disable ListBox items

2019-08-21 13:05发布

问题:

As far as I know, there is no way to grey out/disable specific items in the ListBox control?

I want to make a list of surveys that need to be answered, but grey out/disable those that the user has already answered.

Anyone got some advices how I should do this? Or is there some way to do it with ListBox?

回答1:

You will need to do custom drawing to handle this. Look up OwnerDraw

The typical (and simpler) pattern is just to not include those items in the ListBox.

An alternative would be to use ListView in Details view mode. Then you can modify each item's fore/back colors, font, and more.