Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo Box : Not showing values unless focus is set to it
Message
De
02/12/1998 09:29:55
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00145892
Message ID:
00163185
Vues:
37
David -

Thanks a lot. This really does clear things up, particularly with respect to the impact of refresh!

Sylvia

>Sylvia,
>
>>From your explanation, I guess that's what my cbo.Value=List(1,2) does. But here's a stupid question. Why does DisplayValue choose to show the name (i.e. my first column), whereas value shows the integer (the second column), or is that just the way it is?
>
>Basically yes, that's just the way it is. It's quite a bit better than it was in VFP3 binding to an integer FK value like this was much more work. DisplayValue is "what the user sees", it is always the first column of the RowSource. Value is what the cbo stores to it's ControlSource. Most of the cbos that I use are basically lookups, they display a text value for the user to choose from, but store an integer key in the underlying table.
>
>>Also, I guess I'm confused about why I need to bind to column 2 in the first place to get this to work. Is that because my controlsource is the integer value I'm storing or in other lingo, the aspect which makes it 'bound'?
>
>You could bind to Column 1, but what that requires is your ControlSource to have the full character field stored, so it takes more diskspace. If you bind to column 2 your ControlSource just needs to store is the 4 byte integer key into the lookup table.
>
>>Can you elaborate a little on your explanation of the connection between control source and the row source with respect to how the refresh affects it? Usually doing a refresh is a good thing, but evidently not in this case:)
>
>Refresh() tells a control to look at look at the value of the ControlSource and update the control to display the value. For a simple Textbox it just repaints the display to show the record. For the cbo it has to lookup the value in the BoundTo column, set the DisplayValue based on which row of the RowSource that it finds the value. If it doesn't find the value, the DisplayValue goes blank because there is no match.
>
>For example
>
>
create table LookupTable ( cDescr c(64), iID i )
>for i = 1 to 10
>   insert into LookupTable ( "Item" + str( i ), i )
>endfor
>
>create table MyData ( iID i, iLookUp i ) && iID = PK, iLookUp = FK into LookUpTable
>
>If the cbo RowSource is cDescr, iID, BoundTo = .t., BoundColumn = 2, ControlSource = MyData.iLookUp
>
>If BoundColumn = 1 your MyData table would have to be ( iID i, cLookUp c(64) )
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform