List View Not Adding Items

Report problems with documented functionality
User avatar
Delta Pythagorean
Posts: 422
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

List View Not Adding Items

25 Jul 2017, 19:53

So, I've hit a roadblock and I can't find a reason why this is happening.
I've got my entire code here:

Code: Select all

	AutoHotkey Version:
	Language:						English
	Platform:						Win XP, Win 7, Win 8.1, Win 10
	Author:							Delta
	Contact information:

	|	Hotkeys:											|
	|		None											|

#SingleInstance Force
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
Process, Priority,, H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode, Input

Menu, Tray, Icon, imageres.dll, 63
Gui, Main:-MinimizeBox
Gui, Main:Add, Edit, x0 y25 w750 h20 hwndSearch vSearch gSearchInput,
Gui, Main:Add, Text, x5 y5 w305 h20, Type something in the search bar and watch it filter the options!
Gui, Main:Add, ListView, x0 y50 w750 h315 -Multi +Sort +LV0x1 vLVMain hwndLV
Gui, Main:Show, w750 h365, LV Search

Gui, Main:ListView, LVMain
Loop, 10
	LV_Add("", A_Index)

; First Parameter is the Listview's associated Variable
; Second Parameter is the Gui Number/Name
List := LV_AddList("LVMain", "Main")


; First Parameter is the items previously added in LV_AddList()
; Second Parameter is the Search term OR the variable from the edit.
LV_FilterSearch(List, Search)

LV_FilterSearch(Items, Search) {
	Loop, Parse, Items, |
		If (InStr(A_LoopField, Search))
			Return True
			Return False

LV_AddList(LV_Var, Gui := 1) {
	Gui, % Gui ":Submit", NoHide
	Gui, % Gui ":ListView", % LV_Var
	Loop, % LV_GetCount() {
		LV_GetText(ItemTxt, A_Index)
		Items .= ItemTxt "|"
	Return Items
And I've got my screenshots on what happened most recently and the Gui it created.
LV Gui.PNG (4.83 KiB) Viewed 290 times
The attachment LV Gui.PNG is no longer available
If you know the reason why or a reason why this happened, please do tell me. Thanks.
Posts: 3
Joined: 12 Jul 2017, 15:58

Re: List View Not Adding Items

25 Jul 2017, 23:53

1) In the "Gui, Main:Add, ListView,..." command, you're not defining any columns. I've never done that before, but it appears to simply create one, un-titled column. Presumably, that's why the ListView header is blank.

2) "LV_ModifyCol()" auto-sizes the column widths to fit your data, so it has to be called AFTER you add data to the ListView. It needs to be after your LV_Add() loop. But since you only have one column, it won't have any affect anyway--the width of the single column is defined by the "w750" given when you created the ListView.

3) In your LV_AddList() function, the "LV_Delete()" removes all rows from the ListView, so the following call to "LV_GetCount()" will always return 0 and your loop never gets executed.

4) Your LV_FilterSearch() function doesn't reference the ListView at all, so it won't have any visible effect. I presume you want something more like this:

Code: Select all

    local item
    Loop % LV_GetCount()
        LV_GetText(item, A_Index, 1)
        if (Search == item)
             ; Do something to the ListView such as LV_Modify(A_Index, "+Focus +Select")
and your "Items" list is properly not necessary at all. Good luck.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests