BoundColumn, DisplayValue
These properties relate to multi-column list boxes and combo boxes. BoundColumn determines which column is used to fill the Value property and the ControlSource. DisplayValue contains the value of the first column of the current item or the row number of the current item, or, in a drop-down combo, the text typed in by the user.These properties, although a little tricky to understand, are among those that make lists and combos much easier to manipulate in Visual FoxPro than they were in FoxPro 2.x.
Usage |
oObject.BoundColumn = nColumn nColumn = oObject.BoundColumn oObject.DisplayValue = cFirstColumnValue | cNewValue | nRow nRow = oObject.DisplayValue cFirstColumnValue = oObject.DisplayValue cNewValue = oObject.DisplayValue |
You can even bind the combo's or list's value to a column that isn't displayed. Just set ColumnWidths so the column in question has a width of 0, and set BoundColumn to that column. Using this approach, you can, for example, display the employee name and department, but return the employee ID from the list or combo. With some RowSourceTypes, you can even bind to a column that isn't specified as part of the list or combo. For example, with 2-Alias, you can bind to columns beyond ColumnCount. Same thing for arrays. |
Example |
* If you have a drop-down combo with RowSourceType = 0 * you might do this in Valid IF EMPTY(This.Value) * The user typed in a new item. Add it This.AddItem(This.DisplayValue) This.ListIndex = This.NewIndex ENDIF |
See Also |
BoundTo, ColumnCount, ColumnWidths, ComboBox, ListBox, MultiSelect, RowSource, RowSourceType, Style, Value |