I'm fizzling around, sometimes it works, sometimes not - I miss the basic understanding ..
----------------
I have a Dropdownlist, filled with values from variable "mylist" with A,b,c, d.
A subroutines changes "mylist" - sometimes it contains only a, b; then a,c, d ...
After every call of my subroutine I want to display the new values of "mylist"
Problem:
Sometimes it is displayed correctly, sometimes it merges with the old values, so "old a,b,c,d" plus "new a,b" results in displayed "a,a,b,b,c,d"
Simple question:
How (and what?) reset and refresh the GUI?
Thanks for help!
Refreshing / GuiControl for Dropdownlist Topic is solved
Refreshing / GuiControl for Dropdownlist
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Refreshing / GuiControl for Dropdownlist
If we should be guessing what is in the script at this point, the following passage may help.
GuiControl:
GuiControl:
Tab/DropDownList/ComboBox/ListBox: Value should contain a pipe-delimited list of entries to be appended at the end of the control's list. To replace (overwrite) the list instead, include a pipe as the first character (e.g. |Red|Green|Blue). To make the control empty, specify only a pipe character (|). To have one of the entries pre-selected, include two pipes after it (e.g. Red|Green||Blue). The separator between fields may be changed to something other than pipe. For example, Gui +Delimiter`n would change it to linefeed and Gui +DelimiterTab would change it to tab (`t).
Re: Refreshing / GuiControl for Dropdownlist
Thansk @mikeyww
this is what I already found.
- to set the variable or
- to use "GuiControl"
- or both of it?
this is what I already found.
What does "specify" means?mikeyww wrote: ↑06 Dec 2022, 07:28GuiControl:...To make the control empty, specify only a pipe character (|). ....
- to set the variable or
- to use "GuiControl"
- or both of it?
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Refreshing / GuiControl for Dropdownlist Topic is solved
"Specify" means that this is how you use a parameter with the GuiControl command. It means "indicate" or "provide". An example of "specify" would be, "Authors of forum posts should specify their script when they create a new post."
Or:
Code: Select all
list = Black|White|Red|Green|Blue
Gui, Font, s10
Gui, Add, DropDownList, w250 vsel
Gui, Add, Button , wp Default, Update
Gui, Show,, Colors
updateDDL(list)
Return
ButtonUpdate:
GuiControl, Hide, Update
list = Magenta|Orange|Purple
updateDDL(list)
Return
updateDDL(list) {
GuiControl,, sel, % "|" StrReplace(Trim(list, "|"), "|", "||",, 1)
}
Code: Select all
list = Black|White|Red|Green|Blue
Gui, Font, s10
Gui, Add, DropDownList, w250 vsel
Gui, Add, Button , wp Default, Update
Gui, Show,, Colors
update(list)
Return
ButtonUpdate:
GuiControl, Hide, Update
list := update(list, "Black", "Magenta", "White", "Purple")
Return
update(list, add*) {
list := Trim(list, "|")
For each, item in add
(!Instr("|" list "|", "|" item "|")) && list := item "|" list
GuiControl,, sel, % "|" StrReplace(list, "|", "||",, 1)
Return list
}
Re: Refreshing / GuiControl for Dropdownlist
Yes, of course. But I think my code is on a low level which makes more confusion than information.
But I think in the meantime I found a way (I hope the right one). I had some confusion with the value of the variable and the calling of the control and using of the pipes. Here is now the famous code snippet - which finally is rather trivial..
Code: Select all
; set variable to blank
zeigeliste =
; modify it (add more strings to it)
Loop, Parse, jobliste, `r`n
if (SubStr(A_LoopField,1,2) = gemeinde and subStr(A_LoopField,3,2) = operat)
{
zeigeliste := A_LoopField "|" zeigeliste
}
; write it to GUI, including a leading pipe for deleting the current entry
GuiControl, , Jobname , |%zeigeliste%
; choose the first value of list to avoid the display of an "empty" field
GuiControl, Choose, Jobname, 1
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33
Re: Refreshing / GuiControl for Dropdownlist
I'm glad that you found a way. You have a choice of having your variable include the leading pipe, or simply specifying it in the GuiControl command. That part makes no difference. You picked the second option.