Importing data from the listview in gui2 to combobox on gui1.

Get help with using AutoHotkey and its commands and hotkeys
chngrcn
Posts: 145
Joined: 29 Feb 2016, 08:55

Importing data from the listview in gui2 to combobox on gui1.

26 Sep 2018, 05:58

Hi friends,

in my work, gui in gui.
the problems I want your help include;

- to combobox in gui1;  I want to list the "name" column in listview in gui2.
- If I select the values listed in the combobox in gui1, put the corresponding data in the "email" column in the listview in gui2 into the editbox in gui1.

Thank you in advance for your help.

Code: Select all

#SingleInstance force
#NoEnv
SetBatchLines -1

f = NumberMatch.ini
IfNotExist, %f%
{ ;Sample data
 IniWrite,  1 , %f%, Count, ID#
 IniWrite, |1|, %f%, Count, list
 IniWrite, Jhn De        , %f%, 1, Name
 IniWrite, [email protected]    , %f%, 1, eMail
}


;Gui 1
Gui, Add, Text, w40, Name:
Gui, Add, ComboBox, xm +10 w350
Gui, Add, Text, wp , eMail:
Gui, Add, Edit, wp vEmail
Gui, Add, Button, w75 xm Default, Add



;Gui 2
Gui, 2:+Owner1
Gui, 2:Add, Text, w40, Name:
Gui, 2:Add, Text, wp , eMail:
Gui, 2:Add, Edit, ym w220 vName
Gui, 2:Add, Edit, wp vEmail
Gui, 2:Add, ListView, wp vLV2 gLV2 Grid AltSubmit Multi +HScroll hwndHLV, ID#|Name|eMail 
Gui, 2:Add, Button, xm+50 w75 Default, OK
Gui, 2:Add, Button, x+20 wp, Cancel
Gui, 2:Add, Button, wp x+20 gButtonDelete, Delete
Gui, 2:Add, Button, wp x+20 gButtonEdit, Edit


Gui, Show,,HURDA X
return 

GuiClose:
 ExitApp

LV2:
if !(A_GuiEvent == "I")
		return

	if A_EventInfo
	{
		ControlGet, values, List, Selected,, ahk_id %hLV%
		values := StrSplit(values, "`t")
	}
	else
		values := ""
	
	Loop, 3
		
 GuiControl,, Name, % values[A_Index]
 GuiControl,, Email, %Email%
Return

ButtonEdit:
Gui, Submit, NoHide
 LV_Modify(RowNumber,"",ID,Name,Email)
 IniWrite, %Name% , %f%, %ID%, Name
 IniWrite, %Email% , %f%, %ID%, Email
 GuiControl,     , Name, %Name%
 GuiControl,     , Email, %Email%

return

ButtonAdd:
 Gui, +Disabled
 Gui, 2:Default
 GuiControl,,Name
 GuiControl,,Email
 Gui, Show,,Add
 
 ;FillLV
IniRead, list, %f%, Count, list
Loop, Parse, list, |
{
 If !A_LoopField
  continue
 IniRead, name , %f%, %A_LoopField%, Name
 IniRead, email, %f%, %A_LoopField%, eMail
 LV_Add("",A_LoopField,Name,eMail)

}

LV_ModifyCol(1,0)
Loop,4
 LV_ModifyCol(A_Index+1,"AutoHdr")
 
return

2ButtonOK:
 WinGetActiveTitle, title
 Gui, Submit, NoHide
 If !Name
  return
 Gui, 2:Default
 If (title = "Add") {
  IniRead, ID, %f%, Count, ID#
  IniWrite,% ++ID, %f%, Count, ID#
  IniRead, list, %f%, Count, list
  IniWrite,% list ID "|", %f%, Count, list
  LV_Add("",ID,Name,eMail)

 }
 Else 
 LV_Modify(RowNumber,"",ID,Name,eMail)
 IniWrite, %Name%  , %f%, %ID%, Name
 IniWrite, %eMail% , %f%, %ID%, eMail
return

2GuiClose:
2ButtonCancel:
 Gui, 1:-Disabled
 Gui, 2:Cancel
return

ButtonDelete:
WinGetActiveTitle, title
 Gui, Submit, NoHide

 RowNumber := LV_GetNext()
 If !RowNumber
  return
 Gui, 2:Default
 ;~ Gui, 2:+OwnDialogs

 Msgbox,4, DELETE, Are you sure you want to delete?
 IfMsgBox, No
  return
 LV_GetText(ID,RowNumber)
 IniRead, list, %f%, Count, list
 StringReplace, list, list, |%ID%|, |
 IniWrite, %list%, %f%, Count, list
 IniDelete, %f%, %ID%
 LV_Delete(RowNumber)
return

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], doctorafterman, teadrinker and 221 guests