Listview column autosize "AutoHdr" option fails

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Meroveus
Posts: 44
Joined: 23 May 2016, 17:38

Listview column autosize "AutoHdr" option fails

18 Oct 2018, 20:23

Using the listview example in the docs I cannot get all columns to autosize including the header.

To save you looking it up this is the code:

Code: Select all

; Create the ListView with two columns, Name and Size:
Gui, Add, ListView, r20 w700 gMyListView, Name|Size (KB)

; Gather a list of file names from a folder and put them into the ListView:
Loop, %A_MyDocuments%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)

LV_ModifyCol()  ; Auto-size each column to fit its contents.
LV_ModifyCol(2, "Integer")  ; For sorting purposes, indicate that column 2 is an integer.

; Display the window and return. The script will be notified whenever the user double clicks a row.
Gui, Show
return

MyListView:
if (A_GuiEvent = "DoubleClick")
{
    LV_GetText(RowText, A_EventInfo)  ; Get the text from the row's first field.
    ToolTip You double-clicked row number %A_EventInfo%. Text: "%RowText%"
}
return

GuiClose:  ; Indicate that the script should exit automatically when the window is closed.
ExitApp
When I run this I see:
Image
If I try to do something like:
LV_ModifyCol(2,"Integer AutoHdr") ;the column width suddenly jumps to the entire leftover width in the listview.
I also tried:
LV_ModifyCol(,"AutoHdr") ;thinking that perhaps if I left the column number out it would work -- but sadly no

Is there any simple way to make it look like this:
Image
(other than manually resizing it, which is what I did here...)

Thanks!
Edit: The images didn't come through -- the URLs are:
https://imgur.com/sijfCkA
https://imgur.com/yjsx5ML
They should be public
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Listview column autosize "AutoHdr" option fails

19 Oct 2018, 01:53

Meroveus wrote:
18 Oct 2018, 20:23
If I try to do something like:
LV_ModifyCol(2,"Integer AutoHdr") ;the column width suddenly jumps to the entire leftover width in the listview.
That's exactly the documented behaviour for the last column. So you might want to add an empty last column.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 323 guests