Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AddItem v AddListItem in Combo Boxes
Message
De
19/09/2000 09:55:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/09/2000 06:12:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00417981
Message ID:
00418027
Vues:
25
>I usually populate combo boxes via arrays or cursors, with a description in the 1st row & the actual value in the 2nd.
>
>I recently tried using the AddListItem to populate the control, but I only stumbled across example code in a Marcus Egger book, as there's no real example in the VP or MSDN documentation. After seeing the example, it was fairly easy.
>
>The only thing I find strange with this approach is that all the values need to be character, numerics need to be converted. However, if the bound value is a numeric, the converted numeric is stored without any intervention. What's going on there?
>
>What's the difference in using AddListItem compared to AddItem?
>
>Thanks,
>
> Andy Crawshaw


Andy,
Main difference one uses index and the other (Addlistitem) ItemId to specify row. Generally you (I) prefer to provide ItemId instead of index. While index changes as position of row changes ItemId is unique and doesn't change (sort, rearrange with moverbars etc). IndexToItemid and ItemIdToIndex provide extra control. You can think of ItemId as recno() compared to ActiveRow (Index) in a grid where order is in effect.

'However, if the bound value is a numeric, the converted numeric is stored without any intervention.'
Not quite. With default Bound = .f. controlsource value acts as an 'Index' like in OptionGroup. If bound = .t. then actual bound column value is used. ie:

this.AddListItem('MyItem1',100,1)
this.AddListItem('MyItem2',101,1)
this.AddListItem('MyItem3',102,1)
this.AddListItem('65',100,2)
this.AddListItem('32',101,2)
this.AddListItem('44',102,2)

myValuesInTable = '1,2,3'

With bound = .f. when you move on to record with controlsource value =2 you'd get 'MyItem2' and changing to 'MyItem3' would set value to 3 (Index positions).

With bound .t. however you'd see that none is selected when you move to record with a value different than 65,32,44. Selecting say MyItem1 would set value to 65.

Pls note that I used ItemId starting from 100 to intensify you could choose it freely. They would always be 100,101,102 no matter you sort, rearrange the items.

Cetin

Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform