Source language: Translate to:

combobox question.

General questions about NeoBook

Moderator: Neosoft Support

combobox question.

Postby mr cubefan » Thu Mar 17, 2016 12:27 pm

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!
User avatar
mr cubefan
 
Posts: 27
Joined: Thu Mar 10, 2011 6:23 pm

Re: combobox question.

Postby Gaev » Thu Mar 17, 2016 3:04 pm

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.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: combobox question.

Postby mr cubefan » Fri Mar 18, 2016 2:32 pm

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!
User avatar
mr cubefan
 
Posts: 27
Joined: Thu Mar 10, 2011 6:23 pm

Re: combobox question.

Postby Gaev » Fri Mar 18, 2016 3:22 pm

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.
Last edited by Gaev on Fri Mar 18, 2016 6:22 pm, edited 2 times in total.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: combobox question.

Postby mr cubefan » Fri Mar 18, 2016 5:02 pm

Thanks a lot! the code you posted works like a charm!
Thanks for your help, best regards!
User avatar
mr cubefan
 
Posts: 27
Joined: Thu Mar 10, 2011 6:23 pm


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest