Page 1 of 1

combobox question.

PostPosted: Thu Mar 17, 2016 12:27 pm
by mr cubefan
Hi everyone!, i was wondering if its possible to scroll the contents of a combobox, one by one (up or down), without using the little arrow at the most left of the object, with a pushbutton or any other object. because for the people using my kiosk pc, its a little difficult to select the desired item in the combobox.
Regards!

Re: combobox question.

PostPosted: Thu Mar 17, 2016 3:04 pm
by Gaev
mr cubefan:

The ComboBox will always show the "currently selected item" (blank if none selected)... so you can control which item is shown by changing the value of Variable (to store selected item) e.g.

SetVar "[ComboBox1]" "Cherry" <=== if Variable Contains is set to "item Text"
SetVar "[ComboBox1]" "3" <=== if Variable Contains is set to "Item Number"

So, you can code the "click" Action section of your Button objects (Up, Down, First, Last) to set the value of this variable appropriately.

It is a lot easier if Variable Contains is set to "Item Number" ... and then something like ...

ListBoxGetItem "ComboBox1" "[ComboBox1]" "[ComboBox1Text]"

... to get the actual text value of the shown item.

Re: combobox question.

PostPosted: Fri Mar 18, 2016 2:32 pm
by mr cubefan
Hi Gaev!, thanks for your answer.
First, the combobox is filled at runtime, and never shows the same contents.
Second, the combobox is filled with text only items and must return the text of the select item.
Third, the combobox size is never the same, it could be 2 or 50 items.
What i want to implement are 2 pushbuttons, 1 with an arrow facing up and the other with an arrow facing down, this will let the user to "scroll" (select the next or previous stored combobox item), and almost forgot, the user must not select "out of bounds" items, like item nº0 or, if the combobox is 50 items in size, the 51th item.
Regards!

Re: combobox question.

PostPosted: Fri Mar 18, 2016 3:22 pm
by Gaev
First, the combobox is filled at runtime, and never shows the same contents.

That should not matter.

Second, the combobox is filled with text only items and must return the text of the select item.

Take a look at the command ListBoxGetItem.

Third, the combobox size is never the same, it could be 2 or 50 items.

That should not matter.

What i want to implement are 2 pushbuttons, 1 with an arrow facing up and the other with an arrow facing down, this will let the user to "scroll" (select the next or previous stored combobox item)

Say your ComboBox is called ListBox1 ... and its variable (to store selected item) is set to [ListBox1].

Set its property Variable Contains to Item Number (1,2,3...).

Every time you load (fill) this ComboBox with new content ...
Code: Select all
SetVar "[ListBox1]" "1"


For the "Up Arrow" Button's click section ...
Code: Select all
If "[ListBox1]" "!=" "1"
   Setvar "[ListBox1]" "[ListBox1]-1"
Endif


For the "Down Arrow" Button's click section ...
Code: Select all
ListBoxSize "ListBox1" "[ListBox1Size]"
If "[ListBox1]" "!=" "[ListBox1Size]"
   Setvar "[ListBox1]" "[ListBox1]+1"
Endif


When your pub needs to use the "text value of the selected item"...
Code: Select all
ListBoxGetItem "ListBox1" "[ListBox1]" "[ListBox1TextValue]"


almost forgot, the user must not select "out of bounds" items, like item nº0 or, if the combobox is 50 items in size, the 51th item.

Above code takes care of these scenarios.

Re: combobox question.

PostPosted: Fri Mar 18, 2016 5:02 pm
by mr cubefan
Thanks a lot! the code you posted works like a charm!
Thanks for your help, best regards!