Page 1 of 1

Combobox

Posted: Fri Jan 08, 2010 1:33 am
by andrebit
Hi Friends

Happy 2010!

About combobox, is there a way to Value property get a custom value when we use an array as Items property (instead the normal behavior, ie, Value ger the number of row selected )? Like when Itemsource/Valuesource is used?

My idea is to have another array with values to put into Value property when one item is choose. As if was possible to pass an array to Valuesource.

Something like this:

Define COMBOBOX cbTest;
ITEMS {'Orange','Peach','Apple','Blackberry'};
VALUESOURCE {'14564','23456','87654','76543','14567'}

I was clear??? sorry my awfull english.

Thanks

André


p.s. HMG RULES!

Re: Combobox

Posted: Fri Jan 08, 2010 2:45 am
by Rathinagiri
Does it mean that, if I select Blackberry, the value returned would be 14567?

Even now we can do that using a small work around. Isn't it?

Code: Select all

function definecombo
private aValues := {14564,23456,87654,76543,14567}

define window window1

define combobox cbTest
   ....
   items {'Orange','Peach','Apple','Blackberry'};
end combobox
end window
activate window...
return nil


function findcomboboxvalue
msginfo(str(aValues[window1.cbTest.value]))
return nil


Re: Combobox

Posted: Fri Jan 08, 2010 11:01 am
by andrebit
Exactly Rathinagiri. I use array in combos that way you show, but i think it will be very nice if its possible to put the "return values array" as a property of control. What do you think about? Its worth to add it to HMG wishlist?

regards

André

Re: Combobox

Posted: Fri Jan 08, 2010 1:59 pm
by Rathinagiri
I don't know about the internals and memory leakage because of this implementation. May be Roberto is the right person.

Re: Combobox

Posted: Sat Jan 09, 2010 12:46 am
by Roberto Lopez
andrebit wrote:Hi Friends

Happy 2010!

About combobox, is there a way to Value property get a custom value when we use an array as Items property (instead the normal behavior, ie, Value ger the number of row selected )? Like when Itemsource/Valuesource is used?

My idea is to have another array with values to put into Value property when one item is choose. As if was possible to pass an array to Valuesource.
This is not possible right now, but is a nice feature to add in future versions. I've added to my TODO list.

Meanwhile, you could do something like this:

Code: Select all


aReturenValues := { 'One' , 'Two' , 'Three' }

<...>

MyValue := aReturnValues [ Win1.Combo1.Value ]