Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo box confusion...
Message
From
18/12/2001 20:04:17
 
 
To
18/12/2001 16:56:29
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00595880
Message ID:
00595939
Views:
27
This message has been marked as the solution to the initial question of the thread.
Hello David.

>> When the combobox runs you should only see the values from table1.description and when selecting one of these descriptions the value of table1.textid should replace master.textid. <<

It is precisely this ability to display descriptive (meaningful) text while updating some foreign key value that makes combos so useful. Here is a short explanation from chapter 5 of "1001 Thing You Wanted to Know About VFP"

So what are BoundTo and BoundColumn used for?

These properties determine how the control gets its value. The value of a combo or list box is taken from the column of its internal list that is specified by its BoundColumn. A combo box's DisplayValue, the value that is displayed in the text portion of the control, always comes from column one! Its value, on the other hand, can be taken from any column of its internal list. This means you can display meaningful text, such as the description from a lookup table, at the same time the control gets its value from the associated key. You do not even have to display this associated key in the list to have access to it.

For example, suppose the user must assign a particular contact type to each contact when it is entered. The appropriate contact type can be selected from a DropDown List with its RowSourceType set to 6-Fields, its RowSource set to “ContactType.CT_Type, CT_Key” where CT_Type is the description and CT_Key is its associated key in the ContactType table. To set up the control, first set the DropDown List's ColumnCount to 2 and its ColumnWidths to 150, 0. Then set the BoundColumn to 2 to update the bound field in the Contacts table from the key value instead of the description.

The setting of BoundTo specifies whether the value property of a combo or list box is determined by its List or its ListIndex property. The setting of BoundTo only matters when the control is bound to a numeric data source. If the ControlSource of the combo or list box refers to numeric data, setting the control's BoundTo property to true tells Visual FoxPro to update the ControlSource using the data from the bound column of the control's internal list. Leaving BoundTo set to false here causes the ControlSource to be updated with the control's ListIndex, that is, the row number of the currently selected item.

The easiest way to illustrate how this works is by using a little code that simulates how the setting of the BoundTo property affects the way in which the control’s Value property is updated:
WITH This
  IF .BoundTo
    .Value = VAL( .List[.ListIndex, .BoundColumn] )
  ELSE
    .Value = .ListIndex
  ENDIF
ENDIF
HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform