Combobox control with 2 columns

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller

Post Reply
alexgri
Posts: 1
Joined: Sun May 29, 2016 9:55 pm

Combobox control with 2 columns

Post by alexgri » Sun May 29, 2016 10:47 pm

Hi to all,

Just started experimenting with LC and come from vb environment

Since we normally develop database applications and make heavy usage of dropdown controls which are populated by DB Data, I started having a look at the Combobox control.

One common scenario which I am sure most of you relate to is having such a dropdown with 2 columns - an ID (integer) and a value (typically a string). My question is this, does the Combobox control in LC handle multiple columns, and can the user see the string Value (which in VB is a display value) and the control returns the equivalent ID (edit value) ? I cannot seem to see this anywhere. Hope I am wrong.

Thanks
alex

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Combobox control with 2 columns

Post by jacque » Mon May 30, 2016 7:46 pm

You need to script it a little bit. One way to do it is to store the IDs and labels in a custom property of the button, one line per record. For example, set a custom property named cVals to this:

123 Choice 1
234 Choice 2
345 Choice 3
-- etc

The text of the button would be a list of just the labels. Then script the combo box button:

Code: Select all

on menuPick pItemName
  put lineoffset(pItemName, the cVals of me) into tLine
  put word 1 of line tLine of the cVals of me into tChoice
end menuPick
That will put the ID (which is word 1 of each line) into the the variable tChoice.

Instead of a custom property, you could just as easily put the values list into a script local variable or anywhere else.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

YogiYang
Posts: 27
Joined: Thu Oct 09, 2008 6:09 am

Re: Combobox control with 2 columns

Post by YogiYang » Wed Aug 30, 2017 4:13 pm

I am still a beginner in LC but if we can receive Combo Box dropdown even then what you can do is populate a table/grid with required data keeping it invisible and then when needed move the table/grid under the combo box and show it!

Just my 2cents!
--
Yogi Yang

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Combobox control with 2 columns

Post by jacque » Wed Aug 30, 2017 4:53 pm

True, but it's more work and you'd lose the built-in features of the existing combo box button, such as native appearance on any OS, keyboard control, and all the messages the combo button receives and generates. It's always easier and faster to use a native control if one exists.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Combobox control with 2 columns

Post by FourthWorld » Wed Aug 30, 2017 5:27 pm

YogiYang wrote:I am still a beginner in LC but if we can receive Combo Box dropdown even then what you can do is populate a table/grid with required data keeping it invisible and then when needed move the table/grid under the combo box and show it!
A combobox is a combination of a field for open entry coupled with a drop-down list of pre-established options that can be selected to fill in the field.

By its nature, the string in the field would not seem a good fit for tabular display.

What are you looking to build? Maybe we can point you to a good solution.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

YogiYang
Posts: 27
Joined: Thu Oct 09, 2008 6:09 am

Re: Combobox control with 2 columns

Post by YogiYang » Thu Aug 31, 2017 5:45 am

alexgri wrote:Hi to all,

Just started experimenting with LC and come from vb environment

Since we normally develop database applications and make heavy usage of dropdown controls which are populated by DB Data, I started having a look at the Combobox control.

One common scenario which I am sure most of you relate to is having such a dropdown with 2 columns - an ID (integer) and a value (typically a string). My question is this, does the Combobox control in LC handle multiple columns, and can the user see the string Value (which in VB is a display value) and the control returns the equivalent ID (edit value) ? I cannot seem to see this anywhere. Hope I am wrong.

Thanks
alex
Alex,

Being a VB developer I am just curious as to which ActiveX do you use in VB for showing multiple values in Combobox dropdown?
--
Yogi Yang

Post Reply

Return to “Converting to LiveCode”