ObjectListView doesn't word-wrap

这一生的挚爱 提交于 2019-12-23 17:30:50

问题


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:

  1. Set WordWrap to true on the column to wrap. You've already done that.
  2. Make sure the ObjectListView is owner drawn (set OwnerDraw to true -- this can be done in the Form Designer). The base ListView can't word wrap, so we have to draw the cells ourself.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!