Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #7750 > unrolled thread

Combobox value

Started byLu <lu2k@hotmail.com>
First post2015-02-19 08:12 -0800
Last post2015-02-20 14:47 +0100
Articles 5 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Combobox value Lu <lu2k@hotmail.com> - 2015-02-19 08:12 -0800
    Re: Combobox value D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-02-19 23:13 +0100
      Re: Combobox value Lu <lu2k@hotmail.com> - 2015-02-19 23:57 -0800
        Re: Combobox value D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2015-02-20 13:31 +0100
        Re: Combobox value "Karl-Heinz" <invalid@invalid.invalid> - 2015-02-20 14:47 +0100

#7750 — Combobox value

FromLu <lu2k@hotmail.com>
Date2015-02-19 08:12 -0800
SubjectCombobox value
Message-ID<a08b9cf9-4b00-43bd-b2ff-aec7db90953c@googlegroups.com>
Hi VO-experts!

I have a problem with a Combobox (Type: Drop Down List and Sort = False), when the items of the combobox are repeating with different return values the selection does not work correct. It takes the first item and not the value

eg:
self:oDCcmbTest:FillUsing({{"AA",1},{"BB",2},{"CC",3},{"BB",4},{"CC",5}})  
self:odccmbTest:value := 4  -> currentitemno = 2
self:odccmbTest:CurrentItemNo := 4 -> self:odcmbTEst:value == 2

If I set the value to 4 the current item should be 4 and not 2!!!  When I set the CurrentItemNo the value is not correct. The items can occure more often with different return values.

The V0 Version is 2.8 SP3

Thank you for any hints in advance.
Lu

[toc] | [next] | [standalone]


#7754

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2015-02-19 23:13 +0100
Message-ID<2vncead4j5utu05vpiv7acdnde3li13tfe@4ax.com>
In reply to#7750
On Thu, 19 Feb 2015 08:12:58 -0800 (PST), Lu <lu2k@hotmail.com> wrote:

Hello Lu,
>
>I have a problem with a Combobox (Type: Drop Down List and Sort = False), when the items 
>of the combobox are repeating with different return values the selection does not work correct. It takes the first item and not the value
>
>eg:
>self:oDCcmbTest:FillUsing({{"AA",1},{"BB",2},{"CC",3},{"BB",4},{"CC",5}})  
>self:odccmbTest:value := 4  -> currentitemno = 2
>self:odccmbTest:CurrentItemNo := 4 -> self:odcmbTEst:value == 2
>
>If I set the value to 4 the current item should be 4 and not 2!!!  When I set the CurrentItemNo the value is not correct.
> The items can occure more often with different return values.


I can confirm this behaviour and I think would not expect it either
without thinking too much about it,  but consider this when reading
the help documentation:

"With a two-dimensional array, the first element is called the display
value, and the second element is called the return value.  When an
item is selected, ListBox:TextValue contains the first element (the
display value), and ListBox:Value contains the second element (the
return value"

This suggest that the display and return value are connected: if you
select "BB" (even by setting CurrentItemNo) it will search for -the
first- "BB" and get the return value which is 2 and not 4.

It probably doesn't make sense to display the same value as what is
called "items of choice" to the user even if in the background you
have given that same values BB or CC different return values.

I am not sure why you present the same value more than once but you
will have to add something to BB and CC to make them unique.

Dick

[toc] | [prev] | [next] | [standalone]


#7755

FromLu <lu2k@hotmail.com>
Date2015-02-19 23:57 -0800
Message-ID<37b9646a-e95e-4c3f-a626-df62afa1535b@googlegroups.com>
In reply to#7754
Hello Dick!

Thank you for your answer. The application is used for a transportation company, where the combobox items are locations. In a timetable the user see location1, location2...and it is possible that the company drives from location1 to location2 and from location2 to location1 and from location1 to location3...so there are multiple items with the same name. All locations from the timetable are in a unsorted combobox where the return value is an increasing number. 

the combobox looks like:
name return value
loc1  1
loc2  2
loc3  3
loc2  4
loc3  5

I thought when I set the value self:odccmbloc2:value := 4 then the 4th item is selected. I hope you know the problem.

Lu

[toc] | [prev] | [next] | [standalone]


#7757

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2015-02-20 13:31 +0100
Message-ID<i8aeead3j9ino13ur3dik6kgvb1cmkov9u@4ax.com>
In reply to#7755
On Thu, 19 Feb 2015 23:57:47 -0800 (PST), Lu <lu2k@hotmail.com> wrote:

Hello Lu,
>
>Thank you for your answer. The application is used for a transportation company, where the combobox items are locations. 
>In a timetable the user see location1, location2...and it is possible that the company drives from location1 to location2 and 
> from location2 to location1 and from location1 to location 3...so there are multiple items with the same name. 
>All locations from the timetable are in a unsorted combobox where the return value is an increasing number. 
>
>the combobox looks like:
>name return value
>loc1  1
>loc2  2
>loc3  3
>loc2  4
>loc3  5
>
It's probably not a good idea to use a combobox for that; maybe you
should use a bBrowser. Or otherwise add something to make the
locations unique, like loc2 #2 when the location is visited the second
time. For combobox, loc2 = loc2 which is proved by the behaviour you
mentioned.

Dick

[toc] | [prev] | [next] | [standalone]


#7758

From"Karl-Heinz" <invalid@invalid.invalid>
Date2015-02-20 14:47 +0100
Message-ID<ckosbnFu2boU1@mid.individual.net>
In reply to#7755
Hi Lu,

The "problem" is that the ComboBox sources assume that you use unique named
items *only*. Anyway, try the inherited ComboBox class below, and let us
know if it fits your needs.

------------------------
CLASS mySpecialComboBox INHERIT ComboBox

ASSIGN VALUE ( uValue ) CLASS mySpecialComboBox
LOCAL dwPos AS DWORD
LOCAL uRet AS USUAL

  uRet :=  SUPER:VALUE := uValue


     IF ( dwPos := AScan( SELF:aRetValues, uValue ) ) > 0

        SELF:CurrentItemNo := dwPos


    ENDIF

RETURN uRet


-------------

Regards
Karl-Heinz 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web