F > FComboBox.setDataProvider |  |

FComboBox.setDataProvider

FComboBox, FComboBox.setDataProvider, setDataProvider

Availability

Flash Player 6.

Usage

    myComboBox.setDataProvider(dataProvider)

Parameters

`dataProvider` An array of text strings listing the items to add, an instance of the Array object specifying the items to add, or an instance of the DataProvider class.

Returns

Nothing.

Description

Method; registers an outside object (`dataProvider`) as the data source for the combo box component. If `dataProvider` is an instance of the Array object, the object can specify `label`, `data`, or both, because object properties and the contents of the array can be copied to the combo box as labels, data, or both. If `dataProvider` is an instance of the DataProvider class, it must implement the DataProvider API defined in the DataProvider symbol in the FlashUIComponents/Core Assets/ClassTree folder in the library. The DataProvider API is for advanced users and programmers only; all other users should use an array or an Array object.

Example

The following code specifies the Array object peopleList1 as the data provider for `comboBox1`.

    comboBox1.setDataProvider(peopleList1);

The following code creates the array peopleList to display the labels of the items listed in `comboBox1`.

    peopleList = new Array();
    peopleList[0] = "BHall";
    peopleList[1] = "CMoock";
    peopleList[2] = "MWobensmith";
    peopleList[3] = "MShepherd";

The following code creates the array `itemList1`, which specifies both the label and the data for list items. This array object could be used as an alternate data provider for `comboBox1`.

    itemList1 = new Array();
    for (i=0; i<10; i++) {
    // create a real item
      var myItem = new Object();
      myItem.label = "Item" + i;
      myItem.data = 75;
    // put it in the array
    itemList1[i] = myItem;
    }

The following code specifies `comboData`, an instance of the DataProvider class, as the data provider for `comboBox1`.

    comboBox1.setDataProvider(comboData);

The following code creates a new instance of the DataProvider class and then adds the item labels using the DataProvider `addItem` method.

Note: The `addItem` method is just one method of the DataProvider class. Programmers interested in using the DataProvider class should refer to the DataProvider symbol in the FlashUIComponents/CoreAssets/ClassTree folder in the library before attempting to use the methods.

    comboData = new DataProviderClass();

    comboData.addItem("Devra");
    comboData.addItem("Delia");
    comboData.addItem("Vashti");
    comboData.addItem("Alicia");

See also

`FComboBox.addItem`, `FComboBox.replaceItemAt`, `FComboBox.sortItemsBy`