TListView.TListColumn[x].TWidth := ColumnHeaderWidth?!?!?
I'm trying to get a TLIstView to automatically resize so that all the
data shows (whether the header or the text of a column needs to be
"variable".
The following code worked under Delphi3, but fails under Delphi4:
(LvSystemList is a TListView)
// AdjustFormWidth;
NewWidth := 0;
with LvSystemList do
for Index := 0 to Columns.Count - 1 do
Inc( NewWidth, Column[ Index ].Width );
// Allow for an vertical scrollbar
with LvSystemList do
HasScrollBar := VisibleRowCount < Items.Count;
if HasScrollBar then
Inc( NewWidth, GetSystemMetrics( SM_CXVSCROLL ) );
// Width := NewWidth + ( Width - LvSystemList.Width ) + Fudge;
ClientWidth := NewWidth + ( Width - LvSystemList.Width ) + Fudge;
============
The problem I have discovered is this:
Under Delphi3, when I set the column width of the
TListColumn.Column[x].Width to ColumnHeaderWidth
(LVSCW_AUTOSIZE_USEHEADER;) or ColumnTextWidth (LVSCW_AUTOSIZE), when I
run the above routine, I get the actual width of the column.
When I run this under Delphi4, I get the values
ColumnHeaderWidth/ColumnTextWidth back (-1 and -2 if I recall).
Has anyone else run into this? Is there a better way to do what I am
doing?