问题
I am using ObjectListView instead of the standard ListView is because I wanted to word-wrap the columns.
I read in several places that the only thing I need to to in order to enable word-wrapping is the set column.wordWrap
to true.
I did just that, but it doesn't work.
What am I missing here?
Edit: I realise now that I need to make my column owner drawn. I found this page which sort of tells me what to do, but I'm not sure where to place it in my code. I'm also not quite sure whether I need to add certain attributes inside the delegate to allow word-wrapping (by the looks opf things it's enabled by default). The thing is, I tried what I found in this page, copied it word for word, and my list looks exactly the same...
回答1:
If you mean by "word wrapping", you want different rows to have different heights, the FAQ answer is correct -- it simply can't be done.
However, if you make each row so that it can display two or more lines of text, then, yes, ObjectListView
can word wrap.
It needs three conditions:
- Set
WordWrap
to true on the column to wrap. You've already done that. - Make sure the
ObjectListView
is owner drawn (setOwnerDraw
to true -- this can be done in the Form Designer). The baseListView
can't word wrap, so we have to draw the cells ourself. - Make sure there is room to see the wrapped lines by setting the RowHeight to 32 (or some other value)
This is the data tab from the demo. The first column has WordWrap
set to true.
回答2:
On the ObjectListView SourceForge FAQ page, it explicitly states:
Can it word-wrap?
No.
来源:https://stackoverflow.com/questions/10075111/objectlistview-doesnt-word-wrap