Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo Box not behaving the same as other
Message
From
03/07/2006 16:58:27
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01133388
Message ID:
01133498
Views:
13
didn't assign an init. value to the combo, but it IS bound, to thisform.cOpCode.

The combo's BoundTo property has nothing to do with whether or not it is a bound control (i.e., has a ControlSource specified).

This is how I explained the combo's BoundTo property in Chapter 5 of 1001 Things You Wanted to Know About Visual FoxPro

BoundTo and BoundColumn
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 that 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform