modify row with rightclick , maybe click button 'PAYED' which sends YES to column-3
Code: Select all
;-- example Listview modify with rightclick ---
;-- ahk basic XP
modified=20121212
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
name1=Test
filename1=%name1%-%modified% Edit=RightClick
;--- create a test-file ----
F1=%a_scriptdir%\LV_testbasic.txt
ifnotexist,%f1%
{
e4x=
(Ltrim Join`r`n
Jeff,20,
Garry,19,
)
Fileappend,%e4x%`r`n,%f1%
}
;-----------------------------
T1=110 ;-- width column-1
T2=60 ;-- width column-2
T3=110 ;-- width column-3
tot:=(T1+T2+T3+40) ;-- width listview
xpos=110
gsw:=(xpos+T1+T2+T3+50) ;-- width GUI
Gui,1:Font,S13 CDefault,Lucida Console
Gui,1:Add, ListView,backgroundteal csilver grid r10 x%xpos% y0 w%tot% +hscroll altsubmit gLW2 vLV_1, Name|Age|PAYED
LV_ModifyCol(1,T1) ;-- size
LV_ModifyCol(2,T2)
LV_ModifyCol(3,T3)
Gui,1:Show,x0 y0 w%gsw% h260,%filename1%
gosub,lb
return
;=================================================================================================================
guiclose:
exitapp
LB:
Gui,1:default
LV_Delete()
loop,read,%F1%
{
LR:=A_LoopReadLine
if LR=
continue
LR=%LR% ;-- remove leading space
stringsplit,C,LR,`, ;-- split with delimiter
LV_Add("",C1,C2,C3)
}
LV_ModifyCol(1, "Sort") ;-- sort column-1
LV_ModifyCol(2,"integer")
LV_Modify(LV_GetCount(), "Vis") ;-- scrolls to last line
return
;==============================================================
;============================================================
LW2:
Gui, Submit,nohide
Gui,1:ListView, LV_1
;=================== MODIFY ============
if A_GuiEvent = RightClick
{
LV_GetText(C1,A_EventInfo,1)
LV_GetText(C2,A_EventInfo,2)
LV_GetText(C3,A_EventInfo,3)
RN:=LV_GetNext("C")
RF:=LV_GetNext("F")
GC:=LV_GetCount()
ewd:=(gsw-100)
GuiControl,3:Focus,Name
Gui,3:Font, S10 CDefault , FixedSys
Gui,3:Add,Text, x1 y5 w80 h20, Name
Gui,3:Add,Edit, x80 y5 w%ewd% h20 vA31 limit15, %C1%
Gui,3:Add,Text, x1 y30 w80 h20, Age
Gui,3:Add,Edit, x80 y30 w%ewd% h20 vA32 number limit2, %C2%
Gui,3:Add,Text, x1 y60 w80 h20, PAYED
Gui,3:Add,Edit, x80 y60 w%ewd% h20 vA33, %C3%
Gui,3:Add, Button, x10 y90 w40 h25 gOk1, OK
Gui,3:Add, Button, x150 y90 w90 h25 gPayed, PAYED
Gui,3:Show, x2 y385 w%gsw% h120, MODIFY
return
;---------------------------------------
3GuiClose:
3GuiEscape:
Gui, 3:Destroy
return
Payed:
GuiControl,3:Text,A33,YES
ok1:
Gui,3:submit
FileRead, FileContent, %F1%
FileDelete, %F1%
StringReplace, FileContent, FileContent, %C1%`,%C2%`,%C3% , %A31%`,%A32%`,%A33%
FileAppend, %FileContent%, %F1%
GoSub, LB
Goto,3guiclose
}
return
;=====================================================