Thanks flyingDman. I really appreciate your Help. It turns out that in addition to replacing "row*" with "row" as you suggested, replacing "row*" with [row*] also works. I prefer the semantics of the latter since I am loading listviews with variadic lists of elements from CSV files.
FOR LEXiKOS:
1. AHK v2 documentation gives the following format for the
GUI Add method:
Add method (Gui): MyGui.Add(ControlType , Options, Text)
where:
ControlType is type String
Options is type String
Text type "Depends on the specific control type, a string, number or an array."
The documentaiton does not enumerate which type to use for which control or provide a reference to that information.
This should be fixed.
2. AHK v2 documentation gives the following format for the
ListView Add method:
Add method (ListView): NewRowNumber := LV.Add(Options, Col1, Col2, ...)
where:
Options is type String.
Col1, Col2, ... is type String. The columns of the new row, which can be text or numeric (including numeric expression results).
To make any field blank, specify "" or the equivalent. If there are too few fields to fill all the columns, the columns at the end are left
blank. If there are too many fields, the fields at the end are completely ignored.
There is no mention of inputing Col1, Col2, ... as an array in the documentation. Is type String truely correct for Col1, Col2, ...?
3. AHK v2 documentaiton for
ListView (in the first working script) shows that Cols can be added as an expanded array.
LV := MyGui.Add("ListView", "r20 w700", ["Name","Size (KB)"])
in contrast, (in the same script) cell values appear to be added to the listview as parameters:
LV.Add(, A_LoopFileName, A_LoopFileSizeKB)
Neither format option is enumerated in the documentation so the choice of best/working format remains ambiguous.
From a semantics point of view, the most consistent usage would be to have both methods use parametric inputs. Not only would this get rid of the ambiguity, it would best support variadic loading of both methods. I know that we are now at an alpha release, so I would settle for better documentation and examples showing how to do load listviews with variadic references.
Suggested example:
Code: Select all
;sCSV = CSV formated string. Obtain from file with sCSV := FileRead(Filename)
sCSV := "
( Ltrim Join`n
COL1,COL2,COL3
R1C1,R1C2,R1C3
R2C1,R2C2,R2C3
R3C1,R3C2,R3C3
)"
aCSV := []
Loop Parse sCSV, "`n" {
aElements := []
Loop Parse A_LoopField, "," {
aElements.Push(A_LoopField)
}
aCSV.Push(aElements)
}
MyGui := gui(,"Variadic LV load")
for row in aCSV {
if (A_Index = 1)
lv := MyGui.addListView("", [row*]) ;NOTE: "row" could be used in place of [row*].
else
lv.Add("", row*)
}
MyGui.show()