Dear all,

I would like to do this...
a combo box have this value - apple, boy, cat for user to select
but underlying the value - a, b, or c will store to table instead.
I would like to know how to set up properties properly
and how to show the value correctly to user when retreive from table.

Many thanks.

Wandy

Re: newbie question - combo box by Stefan

Stefan
Sun Nov 30 03:54:20 CST 2003


"W.Tang" <anonymous@discussions.microsoft.com.invalid> schrieb im
Newsbeitrag news:OU%23aAPwtDHA.2456@TK2MSFTNGP12.phx.gbl...
> Dear all,
>
> I would like to do this...

Hi,
Comboboxes are very flexible, so it's difficult to cover all
options in one example, unfortunately.

> a combo box have this value - apple, boy, cat for user to select

If the displayed values are hard-coded, you can use AddItem()
and AddListItem(), for example
PROCEDURE Combo1.Init
This.AddItem("apple") && 1st col
This.AddListItem("a",This.NewItemID,2) && 2nd col
This.AddItem("boy") && 1st col
This.AddListItem("b",This.NewItemID,2) && 2nd col
This.AddItem("cat") && 1st col
This.AddListItem("c",This.NewItemID,2) && 2nd col
ENDPROC
see also the List() method and the examples there and in the
other related topics in help. (see also With / Endwith)

If they come from a lookup table, one way can be to put an
SQL statement into the combo.RowSource property
combo1.RowSourceType=3
combo1.RowSource="Select cName, cValue " + ;
"From LookupTable Into Cursor Sys(2015)"
(w/o quotes in the property sheet)


> but underlying the value - a, b, or c will store to table instead.

combo1.BoundColumn=2

If the value in the second RowSource column is meant to be
numeric, you'll need combo1.BoundTo = .T. additionally
If the value in the second column must not be visible in the
combo dropdown, you'll leave .ColumnCount=1 (default)


hth
-Stefan