# Owl's Blog on .NET development

Component Owl codes Better ListView control all night so you don't have to.

## Vertical Alignment and Text Wrapping in Better ListView

Blog Post by Libor Tinka published on Wednesday, 16 November 2011 in Better ListView, Tutorials

.NET ListView supports horizontal alignment of text in columns, items, sub-items and groups. Since Better ListView adds many new features, like multi-line items and images of arbitrary size, vertical alignment comes in handy.

By default, each view has its defaults, but you can customize text alignment on every column, item, sub-item and group individually:

Vertical alignments of text

The vertical alignment feature is a new property of each element type. For example, .NET ListView item has a property called Align which refers to horizontal alignment. Better ListView extends this to two independent properties called AlignHorizontal and AlignVertical. The naming scheme is same for columns, items, sub-items and groups.

Better ListView also supports splitting text in column headers and items (sub-items) into multiple lines.

We extended this functionality by adding a BetterListViewItem.TextWrapping and BetterListViewSubItem.TextWrapping properties. With these, you can control how the text in sub-items will be wrapped. There are three possible values:

- Layout – the text will be wrapped to multiple lines, up to value specified by MaximumTextLines property of the corresponding view (layout)
- None – the text will not be wrapped at all
- Space – the text will be wrapped, but only to available space (item will never get higher due to wrapping text in sub-item with this setting)

The following screenshot shows these three wrapping modes in action:

Various text wrapping modes

The sub-item in the first column has TextWrapping set to Layout and the layout has MaximumTextLines set to 4. The sub-item text thus can be split to up to four lines. It is actually split just to three because the column is wide enough.

The sub-item in the second column has TextWrapping set to None, which means the text in this sub-item is kept on single line.

The sub-item in the third column has TextWrapping set to Space. As you can see, even if the MaximumTextLines is set to 4, the sub-item text is limited to three lines, preventing item to grow larger.

Tags: alignment, sub-item, text, vertical, wrapping

### One Response to “Vertical Alignment and Text Wrapping in Better ListView”

1. Daniel N says:
   November 17, 2011 at 3:44 am

   Very nice guys… With each new version, Better ListView is doing exactly that: just getting better and better!

   I am particularly keen to try putting in my own linebreaks into items in the details view.

   Reply

### Leave a Reply to Daniel N

Click here to cancel reply.

Name (required)

Mail (will not be published) (required)

Website