سؤال

folks! I use a listview (Icon mode) to display items which consist of an image and a label. As you can see in the shots the row height is variable on y depending on the label length. The problem is that I want the complete labels to be drawn, but they are automatically shrinked into two lines: All strings which are too long have been truncated

The strange thing about it is that once you select an item the whole label will be shown: The selected item is displayed without truncation This is also the case when deselecting the item, but when another item gets selected, only that one will be shown completely. Is there a way (without drawing the text manually) to avoid truncation in my case? If some code is needed to answer this question, don't hesitate to ask.

Greetings, Satara

هل كانت مفيدة؟

المحلول

I'm guessing this was a design choice: make things look less cluttered. E.g. picture your desktop with all labels shown completely... will look messy in my case.

However, you can fix this by drawing the label yourself. Have a look into custom draw which is a service provided by the list control. The thing is that it's usually an all or nothing approach, so this will likely require you to draw everything yourself: border, image, label, etc. The other option is to get hacky: subclass the window and draw the labels again after Windows did in response to several messages (unfortunately Windows does not restrict the painting to WM_PAINT, an optimization that is a left-over from the old days...)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top