Article ID: 179988 - Last Review: February 24, 2004 - Revision: 3.0 FIX: Problem with ListView's ColumnHeader Width PropertyThis article was previously published under Q179988 On This PageSYMPTOMS
When you programmatically set the Width of a ColumnHeader, the width of the
column may actually appear larger than you expect. This presents a problem
when you attempt to save the ColumnHeader Width settings so that you can
restore them at a later time.
CAUSE
Internally, the Width of a ColumnHeader is padded with some predetermined
constant when it is changed programmatically. This padding is not in effect
if the Width of the ColumnHeader is changed through the user interface.
RESOLUTION
To work around this problem, you can set or return a ColumnHeader Width
using the SendMessage API function with the LVM_SETCOLUMNWIDTH or
LVM_GETCOLUMNWIDTH messages.
The constant and function declarations are as follows: To set the Width of a Columnheader using the message LVM_SETCOLUMNWIDTH, you provide the index of the column (starting with 0) as the wParam and the new width as the lParam. For example, the following statement sets the width of the second column (index 1) of ListView1 to 150: To retrieve the Width of a Columnheader using the message LVM_GETCOLUMNWIDTH, you provide the index of the column (starting with 0) as the wParam. The lParam is unused and should be set to 0. For example, the following statement returns the width of the second column (index 1) of ListView1: STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in Visual Basic 6.0.
MORE INFORMATIONSteps to Reproduce Behavior
APPLIES TO
| Article Translations
|

Back to the top
