Add Multiple Data in Single ListView Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Add Multiple Data in Single ListView

27 Dec 2019, 02:29

hello all and good day,
I want to add multiple data in 1 list view but not working properly(Data1 on the left, Data2 on the right in 1 Row), any help will be appreciated.

here's my code so far

Code: Select all

Gui Add, ListView, x5 y5 w1000 h500, Data1|Data2

Loop,%A_Desktop%\*.*	; example
    LV_Add("",, A_LoopFileName)
Loop,%A_MyDocuments%\*.*	; example
    LV_Add("", A_LoopFileName)

LV_ModifyCol(1)  ; Data1
LV_ModifyCol(2)  ; Data2
Gui, Show
Return

GuiEscape:
GuiClose:
    ExitApp
Thank You
just me
Posts: 9574
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Add Multiple Data in Single ListView  Topic is solved

27 Dec 2019, 06:58

Code: Select all

#NoEnv
Gui Add, ListView, x5 y5 w1000 h500, Data1|Data2
Loop,%A_Desktop%\*.*		; example Data1
   LV_Add("", A_LoopFileName)
Data1Rows := LV_GetCount()
Loop,%A_MyDocuments%\*.*	; example Data2
   If (A_Index <= Data1Rows)
      LV_Modify(A_Index, "Col2", A_LoopFileName)
   Else
      LV_Add("", , A_LoopFileName)
LV_ModifyCol(1)  ; Data1
LV_ModifyCol(2)  ; Data2
Gui, Show, , LV Test
Return

GuiEscape:
GuiClose:
ExitApp
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Add Multiple Data in Single ListView

27 Dec 2019, 09:10

Or, using an Array:

Code: Select all

Gui Add, ListView, x5 y5 w1000 h500, Data1|Data2
lst := []
Loop,%A_Desktop%\*.*		
   lst[A_Index,1] := A_LoopFileName
Loop,%A_MyDocuments%\*.* 
   lst[A_Index,2] := A_LoopFileName
Loop, % lst.MaxIndex() {
   LV_Add("",lst[A_Index]*)
}
LV_ModifyCol()
Gui, Show
Return

GuiEscape:
GuiClose:
ExitApp
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Add Multiple Data in Single ListView

27 Dec 2019, 10:25

@just me and @Odlanir

Thank you very much, all your code works very well :clap: :bravo: :dance: :superhappy:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 238 guests