View Issue Details

IDProjectCategoryView StatusLast Update
0029132LazarusIDEpublic2016-12-22 13:37
ReporterLionAssigned ToMichl 
Status resolvedResolutionfixed 
PlatformIntelOSWindowsOS Version7
Product Version1.4.4Product Build 
Target VersionFixed in Version1.7 (SVN) 
Summary0029132: ListView Column Width always changing

I set the width to fixed, but it is changing, always alone. After a period of time or if the Application is more mals is compiled.

TagsNo tags attached.
Fixed in Revisionr53746
Attached Files


related to 0031153 closedJuha Manninen Access Violation by open new project after editing a property of TListView.Columns 


Zeljan Rikalo

2015-12-03 15:27

developer   ~0087773

Please attach example project.


2015-12-03 19:34

reporter   ~0087779

Last edited: 2015-12-03 19:49

View 3 revisions

All projects have this bug. See Screenshot01.

Column Firstname = 64 Width
run project column Firstname = 544 Width
After several compile is the column Firstname in the object inspector = 544 Width


2015-12-03 19:43


Screenshot01.PNG (300,763 bytes)


2015-12-03 19:51

reporter (584,544 bytes)


2016-12-17 21:46

developer   ~0096860

Last edited: 2016-12-17 21:50

View 2 revisions

> Pls close?

No, this bug report is valid.

Column 0 and 1 has AutoSize = true, column 2 not.
If you set column 2 to xxx value, column 0 and 1 should get the same size: (ClientWidth - Column-2.Width) div 2. This is, what Delphi does (btw. Delphi has also problems, it works only, if you resize the TListView by hand there).

Alexey Tor.

2016-12-20 15:39

reporter   ~0096951

Autosize: seems it is sizing to column max string len. Not like Michl writes.

function TListColumn.GetWidth: TWidth;
  LV: TCustomListView;
  WSWidth: integer;
  if WSReadAllowed
  then begin
    LV := TListColumns(Collection).FOwner;
    WSWidth := TWSCustomListViewClass(LV.WidgetSetClass).ColumnGetWidth(LV, Index, Self);
    // update stored width
    if WSWidth >= 0 then
      FWidth := WSWidth;
  Result := FWidth;

I see column gets size from WS level. So even if I set last column to 100, i see in IDE its size=223 (Ubuntu sizes last column). crap. Better dont get from WS here?


2016-12-21 08:12

developer   ~0096982

> Autosize: seems it is sizing to column max string len. Not like Michl writes.

Yes and no.

The documentation of Delphi says: Specifies whether the list column automatically sizes itself to the width of its text (

The current behaviour in Delphi Berlin is a other one. All autosized columns are sized to fit in the client area. You have to set manually the width in the autosized columns to -1, to enable the documented autosized behaviour (maybe a Delphi bug or undocumented feature):


2016-12-21 09:29

developer   ~0096983

As my first post 0029132#c96860 is a undocumented feature or bug in Delphi, I can see only one issue here.

The column width isn't calculated right, if there are no items inside the TListView (@Lion: your picture shows the situation). I fixed it in r53746 for Win32. Tested with


2016-12-21 09:29

developer (3,512 bytes)


2016-12-21 09:37

developer   ~0096984


When I test your app, everything works fine here (Windows 7, Lazarus trunk), except when no items inside the TListView, see node before. If some items are inserted, the first and the second column are autosized to the longest entry of the column.

To the description of your bug report:
If you don't want the last column sized to fit in the client area, you have to disable ListView1.AutoWidthLastColumn.

Please test and close if ok.


2016-12-21 10:25

developer   ~0096985

Last edited: 2016-12-21 10:26

View 2 revisions

Everything is fine when I setup a fresh listview. But still, there is something wrong. Use the OP's demo, turn off AutoWidthLastColumn, turn off all AutoSize. Set the width of column 0 to 100. Now turn on AutoSize of column 0 again. At designtime, the width of column 0 adapts to the width of the caption because there are no other texts in the column - that's fine. But when you run the column width jumps to 544 again.

This observation is made with Win 10, I did not test Win 7.


2016-12-21 10:50

developer   ~0096986

Thanks for that hint! Later, I'll look at it.


2016-12-21 22:20

developer   ~0097004


> At designtime, the width of column 0 adapts to the width of the caption

I tested it on Win 7 and 10, here it isn't changed to the caption width. Here it has the value 100 setted before.

> But when you run the column width jumps to 544 again.

This I also can't see, it is 100 here.

I've tested a fresh rebuilded 32bit Lazarus trunk on Windows 10 and downloaded the project here again. I made exactly the steps, you wrote.

I don't know more (but I see a bug in Object Inspector, maybe it is broken somehow, I'll make a new bug report for that).


2016-12-21 23:13

developer   ~0097005

Last edited: 2016-12-21 23:19

View 3 revisions

Strange... On Win 10, I tried another Laz trunk, now with fpc trunk, I tried Laz 1.6.2/fpc 3.0, Laz 1.6/fpc 3.0 (64 bit - the others are 32-bit) and 1.4.6/fpc 2.6.4, and on a VM with Win 7, I tried another (relatively recent Laz trunk/fpc 3.0) - all systems show the same error: at runtime, the width of the first colum is 544.


2016-12-21 23:26

developer   ~0097006

> I tried Laz 1.6.2/fpc 3.0, Laz 1.6/fpc 3.0

Yes, there should be the error.

> I tried another Laz trunk, now with fpc trunk

There, in revision 53746, it should be fixed. If not, maybe it is related to 0031153.


2016-12-22 00:34

developer   ~0097008

Hmm... Yes, the column width 544 is history now. But still there is a minor issue if the listview is empty like in this demo: Follow my instructions again in which you set the width of column 0 to 100 with AutoSize turned off. Then turn AutoSize on again - note that the width of the column does not change, it should collapse to 64. Run the demo, it will also show the column to be wider than the column title.

If, on the other hand, the ListView is NOT empty then the column width behaves correctly.


2016-12-22 12:57

developer   ~0097012

OK, I changed it in revision 53757. Now, the width is calculated by the caption width, if there are no items in the list view. Tested with Windows 7 and 10 and also HighDPI.


2016-12-22 13:37

developer   ~0097013

Perfect! Thank you.

Issue History

Date Modified Username Field Change
2015-12-03 14:22 Lion New Issue
2015-12-03 15:27 Zeljan Rikalo LazTarget => -
2015-12-03 15:27 Zeljan Rikalo Note Added: 0087773
2015-12-03 15:27 Zeljan Rikalo Status new => feedback
2015-12-03 19:34 Lion Note Added: 0087779
2015-12-03 19:34 Lion Status feedback => new
2015-12-03 19:43 Lion File Added: Screenshot01.PNG
2015-12-03 19:46 Lion Note Edited: 0087779 View Revisions
2015-12-03 19:49 Lion Note Edited: 0087779 View Revisions
2015-12-03 19:51 Lion File Added:
2016-12-17 21:46 Michl Note Added: 0096860
2016-12-17 21:50 Michl Note Edited: 0096860 View Revisions
2016-12-20 15:39 Alexey Tor. Note Added: 0096951
2016-12-21 08:12 Michl Note Added: 0096982
2016-12-21 09:29 Michl Note Added: 0096983
2016-12-21 09:29 Michl File Added:
2016-12-21 09:37 Michl Fixed in Revision => r53746
2016-12-21 09:37 Michl LazTarget - => 1.6.4
2016-12-21 09:37 Michl Note Added: 0096984
2016-12-21 09:37 Michl Status new => resolved
2016-12-21 09:37 Michl Fixed in Version => 1.7 (SVN)
2016-12-21 09:37 Michl Resolution open => fixed
2016-12-21 09:37 Michl Assigned To => Michl
2016-12-21 10:25 wp Note Added: 0096985
2016-12-21 10:25 wp Status resolved => assigned
2016-12-21 10:25 wp Resolution fixed => reopened
2016-12-21 10:25 wp Status assigned => feedback
2016-12-21 10:26 wp Note Edited: 0096985 View Revisions
2016-12-21 10:50 Michl Note Added: 0096986
2016-12-21 10:50 Michl Status feedback => assigned
2016-12-21 22:20 Michl Note Added: 0097004
2016-12-21 22:20 Michl Status assigned => feedback
2016-12-21 22:52 Michl Relationship added related to 0031153
2016-12-21 23:13 wp Note Added: 0097005
2016-12-21 23:16 wp Note Edited: 0097005 View Revisions
2016-12-21 23:19 wp Note Edited: 0097005 View Revisions
2016-12-21 23:26 Michl Note Added: 0097006
2016-12-22 00:34 wp Note Added: 0097008
2016-12-22 12:57 Michl Note Added: 0097012
2016-12-22 12:57 Michl Status feedback => resolved
2016-12-22 12:57 Michl Resolution reopened => fixed
2016-12-22 13:37 wp Note Added: 0097013