Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectListView doesn't word-wrap

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...

like image 525
Superman2625 Avatar asked Feb 21 '23 21:02

Superman2625


1 Answers

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. Word wrap in action

like image 139
Grammarian Avatar answered Feb 23 '23 11:02

Grammarian