ListView Label Multi-Line

Hello,

I have a listview in report-mode, with multiple columns. The columns have column header (column title). But on some columns, the column title text is too long and I want to split the text on two lines. That is, something like adding a new-line within the text of the title so that the text is displayed on two line. Yes, the height of the heading (title) row will increase.

How can I do it?

Thanks in advance,
-Matt
Last edited on
The List View Control does not provide built-in support for multi-line headers; you'll have to use the custom draw mechanism (handle the NM_CUSTOMDRAW messages from the Header control.)

This article discusses how to do it using MFC (the CListCtrl class wraps the List View Control.) Unfortunately, the achive containing the example source code is corrupt.

Multiline Header Control Inside a CListCtrl
http://www.codeguru.com/cpp/controls/listview/headercontrol/article.php/c953/Multiline-Header-Control-Inside-a-CListCtrl.htm

The LVM_GETHEADER message allows you to obtain the HWND to a List View control's Header control, just in case that helps.

Andy

List View
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774737%28v=vs.85%29.aspx

LVM_GETHEADER message
http://msdn.microsoft.com/en-us/library/windows/desktop/bb774937%28v=vs.85%29.aspx

Header Control
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775239%28v=vs.85%29.aspx

NM_CUSTOMDRAW (header) notification code
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775300%28v=vs.85%29.aspx

Last edited on
Also, while it's not using a List View Header, the Microsoft Windows SDK sample MFPlayer2 shows how to handle NM_CUSTOMDRAW to draw a button in its various states.

(See ThemedButton.h and ThemedButton.cpp in the ...\multimedia\mediafoundation\MFPlayer2 subfolder of the SDK's folder.)

Andy

PS My SDK is installed in the default location (for a 32-bit computer):
C:\Program Files\Microsoft SDKs\Windows\v7.0\Samples
Last edited on
Topic archived. No new replies allowed.