Article ID: 129329
Article Last Modified on 2/22/2005
Data Property Description
----------------------------------------------------------------
ColumnCount Number of columns contained in the ListBox object.
RowSource Source of the values displayed in the ListBox object.
RowSourceType Data type of the values. For example, fields, array, list,
files, and list of fields are all valid data types.
ControlSource Where the value chosen by the user is stored. For example,
the value may be stored in a variable.
BoundColumn The column of a multiple-column array to return when the
user selects an object from the ListBox object.
Display
Attribute Description
---------------------------------------------------------------------
Moverbars Allows the rearrangement of values displayed in the
ListBox object.
Multiselect Allows users to choose multiple items from the
ListBox object.
FontName The font used in displaying the ListBox control's data.
FontItalic Turns on italic mode for the font specified in the
FontName property.
CREATE FORM LISTTEST
SELECT cust_id, contact, phone FROM customer INTO ARRAY Thisform.myarrayNOTE: The prefix "Thisform" in front of the array name is a Critical and subtle point to remember about the scoping of member arrays and variables within a form. If the SELECT statement is simply done INTO ARRAY myarray, the array created by the SQL statement will not have scope within the form itself. By prefacing the array name with the "Thisform" clause, the results of the SQL statement are directed into the array named myarray, which is part of the form definition.
- BoundColumn = 1This property governs which column of a multiple-element array is returned to the List1.Value data element when a user selects a record in the ListBox. In this example, you are creating a three-column array, so you can use a value of 1, although 2 or 3 are also valid entries for this property.
- NumberOfElements=ALEN(THISFORM.MYARRAY,1)This property governs the total number of elements that will be displayed in the ListBox. It is valid only for a RowSourceType of 5. By using the =ALEN(THISFORM.MYARRAY,1) expression, you are telling FoxPro to display all the values in the array as opposed to limiting how many elements are displayed. Note that you must type the leading equals sign.
- RowSource = THISFORM.MYARRAYThis RowSource property tells Visual FoxPro that the data will be coming from an object called MYARRAY.
- RowSourceType = 5 - ArrayThis RowSourceType property tells Visual FoxPro that the type of object that contains the data is an array.
- ColumnCount=3This property governs how many elements of the array will be displayed. Because the array that will drive this ListBox contains three columns, the value of 3 is used. Array elements are displayed in the order they appear in the array. For example, say you issue an SQL SELECT statement such as this:
SELECT cust_id, contact, phone FROM CUSTOMERThen the data in the ListBox will be displayed in that order (cust_id, contact, phone).
- ColumnLines = .T.This property determines whether or not to display bars between the columns displayed in the array.
- ColumnWidths = 60,220,90By default, the pixel is the unit of measurement on a Form.
=MESSAGEBOX(THISFORM.LIST1.VALUE,64)When you double-click an item in the list, your selection will be shown in a message box with an OK button.
RELEASE THISFORMChange the caption to Quit.
LISTTEST.LIST1.MultiSelect=.T. && Turn on multiselect property.
LISTTEST.LIST1.FontName="MS Sans Serif" && Change font for ListBox.
LISTTEST.LIST1.FontItalic=.T. && Make the text italic.
LISTTEST.List1.BoundColumn=3 && Alter what column's data is
&& returned to List1.Value.
&& When you change this and then
&& double-click a record, the
&& data from the third column will
&& be returned to LIST1.VALUE.
Additional query words: Multiselect multicolumn multi-select multi-column
Keywords: kbhowto kbdesigner KB129329