
ListView column width = ListView width ?
Try calling it after. The LVSCW_AUTOSIZE_USEHEADER message is a bit
misleading in name ... this message instructs that, when the column is the
last (or only) column in the control, that it should occupy "all remaining"
header space. IOW, as wide as the control. I tested just that code before
posting, and it works. As I said, if you call it before, the header is the
width of the control. If you then add items that create the scrollbar, the
scrollbar will cover the end of the header. If you call it after, the
presence / absence of the scrollbar is taken into consideration.
--
Randy Birch
MVP Visual Basic
Take the vb.net poll at:
http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/
Please respond only to the newsgroups so all can benefit.
: Hey Randy,
:
: first of all thanks alot for answering!
:
: > Easiest sure-fire way ....
: >
: > Const LVM_FIRST As Long = &H1000
: > Const LVM_SETCOLUMNWIDTH As Long = (LVM_FIRST + 30)
: > Const LVSCW_AUTOSIZE_USEHEADER As Long = -2
: >
: > Call SendMessage(ListView1.hwnd, _
: > LVM_SETCOLUMNWIDTH, _
: > 0, _
: > ByVal LVSCW_AUTOSIZE_USEHEADER)
: >
: > Call this after you add the data to the listview. It will resize the
: column
: > to fit the display width, and will take into account the scrollbar if
: > visible. If you call it before adding the data the header will set to
the
: lv
: > width without taking the scrollbar into account, if present.
:
: This didn't work. I called the function before I added the data. All I did
: was adding one single column header to the empty listview. This very
column
: header is the one that should fit to the size of the listview control.
:
: The effect of calling the SendMessage function is the same as using what I
: typed before:
:
: lvListView.ColumnHeaders.Item(1).Width = .lvListView.Width
:
: So ... nothing changed.
:
: I'm using VB6.0 SP4 if this is any help. Thanks alot,
:
: Andre
:
:
:
:
: