Delete list function for 2 listview in GUI**Need Help Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Pardeep Tariyal
Posts: 53
Joined: 30 Aug 2017, 08:43

Delete list function for 2 listview in GUI**Need Help

21 Jun 2018, 10:31

Hi

I am tring to create a 2 listview in one gui. everyting working fine except delete option. I have assigned delete option in right click. Delete option working for 2nd list but not sure how to make this workable for 1st list. Even, it is deleting the row from 2nd list whether row is seleted from 1st list.

Here is my code

Code: Select all

Gui, Add, ListView, x10 y35 h200 w380 vlist1, Name                     |Date Created
Menu, MyContextMenu, Add, Delete, Delete
Gui, Add, ListView, x10 y250 h200 w380 vlist2, Name                     |Date Created
Gui, Show, x500 y200 h500 w400, The List
Gui,1:ListView, list1
Loop, %A_ScriptDir%\Temp_Files\*.*
LV_Add("", A_LoopFileName, A_LoopFileTimeCreated)
Gui,1:ListView, list2
Loop, %A_ScriptDir%\Other_Temp_Files\*.*
LV_Add("", A_LoopFileName, A_LoopFileTimeCreated)

Return

GuiContextMenu:
LV_GetText(RowText, A_EventInfo)
Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
Return
Delete:

FileDelete, %A_ScriptDir%\Temp_Files\%RowText%
Rownumber := LV_GetNext(RowText, "F")
LV_Delete(Rownumber)

Return
User avatar
TheDewd
Posts: 1131
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Delete list function for 2 listview in GUI**Need Help  Topic is solved

21 Jun 2018, 10:58

Example:

Code: Select all

#SingleInstance, Force

Menu, MyContextMenu, Add, Delete, Delete

Gui, Margin, 10, 10
Gui, Add, ListView, w600 r10 vList1, Name|Date Created
Gui, Add, ListView, y+10 wp hp vList2, Name|Date Created
Gui, Show, AutoSize, Example

; Add items to ListView 1 ======================================================
Gui, ListView, List1

Loop, %A_ScriptDir%\*.*
{
	LV_Add("", A_LoopFileName, A_LoopFileTimeCreated)
}

; Resize columns to fit contents -----------------------------------------------
Loop, % LV_GetCount("Column")
{
	LV_ModifyCol(A_Index, "AutoHdr")
}

; Add items to ListView 2 ======================================================
Gui, ListView, List2

Loop, %A_ScriptDir%\*.*
{
	LV_Add("", A_LoopFileName, A_LoopFileTimeCreated)
}

; Resize columns to fit contents -----------------------------------------------
Loop, % LV_GetCount("Column")
{
	LV_ModifyCol(A_Index, "AutoHdr")
}
return

GuiContextMenu:
	If (A_GuiControl <> "List1" && A_GuiControl <> "List2") {
		return
	}

	Gui, ListView, % A_GuiControl
	LV_GetText(RowText, A_EventInfo)
	Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
return

Delete:
	Rownumber := LV_GetNext(RowText, "F")
	LV_Delete(Rownumber)
return
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Mipha and 57 guests