Sver
Full Member
Posts: 145
|
Post by Sver on Dec 19, 2018 4:02:44 GMT -5
Hello,
A combobox is normally used for input, but i want to use the same form for output.
When sel$ is "four", is it possible to select it automatically, without 4* if ?
I did tried different things, select,... but it didn't work.
' combox for output/display ?
sel$="four"
nomainwin
a$(1) = "one"
a$(2) = "two"
a$(3) = "three"
a$(4) = "four"
combobox #win.combo, a$(),[doCombo],10,10,120,200
open "Combobox Demo" for window as #win
#win "trapclose [quit]"
if sel$="four" then #win.combo "selectindex 4"
wait
[quit]
close #win
end
[doCombo]
#win.combo "selection? sel$"
notice "You chose ";sel$
wait
|
|
|
Post by Rod on Dec 19, 2018 6:13:35 GMT -5
Not sure what is not working for you. You can select any item in the list and display it with selectindex.
' combox for output/display ?
sel$="four"
nomainwin
a$(1) = "one"
a$(2) = "two"
a$(3) = "three"
a$(4) = "four"
combobox #win.combo, a$(),[doCombo],10,10,120,200
open "Combobox Demo" for window as #win
#win "trapclose [quit]" #win.combo "disable"
timer 500, [change] wait
[change] index=index+1 if index=5 then index=1 #win.combo "selectindex ";index wait
wait
[quit]
timer 0 close #win end
[doCombo]
#win.combo "selection? sel$" notice "You chose ";sel$ wait
|
|
|
Post by metro on Dec 19, 2018 6:30:51 GMT -5
I'm not sure if I understand the problem exactly this is my guess there will be better ideas though....
' combox for output/display ? 'input sel$
'ADD REM to change behavior sel$="four"
nomainwin
a$(1) = "one"
a$(2) = "two"
a$(3) = "three"
a$(4) = "four"
combobox #win.combo, a$(),[doCombo],10,10,120,200
open "Combobox Demo" for window as #win
#win "trapclose [quit]" #win.combo, "reload" #win.combo, "selectindex 1"
IF sel$<>"" THEN for a = 1 to 4 if a$(a) = sel$ then #win.combo, "selectindex "; a end if next a goto [doCombo] 'OR notice "You chose ";sel$ END IF
wait
[quit]
close #win
end
[doCombo]
#win.combo "selection? sel$"
notice "You chose ";sel$
wait
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Dec 19, 2018 6:31:36 GMT -5
Hello Rod,
I have only one user form for input and output for a database.
I can choose someting i a combobox and save it to a record. When i choose a other record in the database, the variable (sel$) is different.
May'be " three"
Is it possible to set the listbox automatically, on right index, when the variable is "three" In this case, i want to print/set the variable to the listbox automatically to index three.
I can do it with 4 times with "if", but may.be there is a easier way to do it.
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Dec 19, 2018 6:44:16 GMT -5
Hello Metro,
That is a solution for the problem. Thanks ! I aspected someting to do with "select" for a "build in" code, for a shorter way.
|
|
|
Post by tsh73 on Dec 19, 2018 7:58:06 GMT -5
Still not sure about what result is wanted. How's that - you click on list it selects same item in combobox?
nomainwin a$(1) = "one" a$(2) = "two" a$(3) = "three" a$(4) = "four"
msg$="Click in List to got same item selected in Combo"_ +chr$(13)+chr$(13)+"Select in combobox to get notice"
combobox #win.combo, a$(),[doCombo],10,10,120,200 listbox #win.list, a$(),[doList],150,10,120,200 STATICTEXT #win.st1, msg$, 10, 50, 120, 200
open "Combobox Demo" for window as #win #win "trapclose [quit]" #win.list, "singleclickselect" wait
[quit] close #win end
[doCombo] #win.combo "selection? sel$" notice "You chose ";sel$
wait
[doList] #win.list "selection? sel$" #win.combo "select ";sel$ ' notice "You chose ";sel$ wait
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Dec 19, 2018 9:10:48 GMT -5
Tsh73,
Thanks, I was looking for #win.combo "select "; sel$
' combobox for output/display ? sel$="four"
nomainwin a$(1) = "one" a$(2) = "two" a$(3) = "three" a$(4) = "four" combobox #win.combo, a$(),[doCombo],10,10,120,200 open "Combobox Demo" for window as #win #win "trapclose [quit]"
#win.combo "select "; sel$
wait
[quit] close #win end
[doCombo] #win.combo "selection? sel$" notice "You chose ";sel$ wait
|
|