RowSource, RowSourceType
These two properties combine to determine the contents of a list box or combo box. RowSourceType indicates the type of data contained, while RowSource contains either the actual data or a pointer to it.
Usage |
oObject.RowSourceType = nSourceType nSourceType = oObject.RowSourceType oObject.RowSource = cSource cSource = oObject.RowSource |
RowSourceType |
Meaning |
RowSource Contents |
0 |
None |
Nothing—combo or list data is added using either the AddItem or AddListItem methods or by directly populating List or ListItem. |
1 |
Value |
The actual items for the list or combo as a comma-separated list. If ColumnCount is more than 1, the items are distributed into all the columns going across one row at a time. Don't leave spaces after the commas; these are interpreted as the first character of the next item. No need to put quotes in the list, either, as they're also interpreted as part of the items. |
2 |
Alias |
The alias for an open table whose data is used to populate the list or combo. If ColumnCount is greater than 0, the first ColumnCount fields are shown. If ColumnCount is 0, you see the first field only, just as if ColumnCount were 1. |
3 |
SQL Statement |
A SELECT-SQL statement, the results of which populate the list or combo. ColumnCount is treated as with RowSourceType=2. Be sure to do something with the query results—if there's no INTO clause, a Browse appears when the query executes on the way into the form. |
4 |
Query |
The name of a QPR file. The query is run and the results populate the list or combo. ColumnCount is treated as with RowSourceType=2. Again, make sure you send the results INTO somewhere or you'll see the default Browse. |
5 |
Array |
The name of an array used to populate the list or combo. If the array is a property of an object, be sure to precede its name with a reference to the object (such as "This" or "ThisForm.") If ColumnCount is greater than 0, the first ColumnCount columns of the array are used. |
6 |
Fields |
A list of fields from a single table. Only the first field should be preceded by the alias of the table. Field names are comma-delimited. Normally, the number of fields in the list should equal ColumnCount. |
7 |
Files |
A file skeleton. The list or combo is populated with the names of files in the current directory matching the skeleton, plus items for navigating directories. Make sure ColumnCount = 1 or 0 or you'll get really weird results. |
8 |
Structure |
The alias of an open table. The list or combo is populated with the names of fields from the specified table. Field names occupy the first column. Any other columns are empty. |
9 |
Popup |
The name of a popup defined elsewhere. The popup's items are used to populate the list or combo. |
It's not just making a choice in a combo that moves the record pointer. Simply passing the mouse over an item in a dropped combo so that the item is highlighted is enough to position the record pointer on that item. The pointer doesn't go back where it came from if you close the combo without making a selection. |
Doubling the backslash doesn't work with RowSourceType 5. Once there's a backslash in front of the text, the item is disabled. A double backslash shows up as a disabled item that begins with a backslash. |
In VFP 7, divider lines don't hit either side of the list or combo. In earlier versions, divider lines correctly run from one edge to the other. It's likely that having the lines not go all the way to the edges is by design, but the actual implementation is still flawed—the lines simply don't go far enough. |
Example |
* This code in the Init for a list box populates * an array that's a property of the form and * sets the list to use the array. SELECT Last_Name,First_Name,Employee_Id ; FROM Employee ; INTO ARRAY ThisForm.aEmps This.RowSourceType = 5 This.RowSource = "ThisForm.aEmps" This.ColumnCount = 2 This.ColumnWidths = "80,60" * This code in the Init of a form * populates a combo on that form * with selected items from Customer. * It assumes the combo's RowSourceType is * set to the default 0. ThisForm.cboFaxTo.ColumnCount=2 ThisForm.cboFaxTo.ColumnWidths="150,120" SELECT Customer SCAN FOR NOT EMPTY(Fax) WITH ThisForm.cboFaxTo .AddListItem(Company_Name,.NewItemId+1,1) .AddListItem(Contact_Name,.NewItemId,2) ENDWITH ENDSCAN |
See Also |
AddItem, AddListItem, ColumnCount, ComboBox, List Property, ListBox, ListItem |