# Populate from Data Source (Drop Boxes and List Boxes)

> Source: https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source

When creating data classes for **[Drop Boxes](https://manual.pvxplus.com/data-dictionary/data-classes/dropbox#display)** and **[List Boxes](https://manual.pvxplus.com/data-dictionary/data-classes/listbox#display)**, a *Load From File* check box (on **Display** tab) can be selected, which allows a data table/file to be defined as the source when populating a Drop Box or List Box at run time.

|  |  |  |
| --- | --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/86fb9be3c310ab55490ba8e3d1ea811e4586313aaf05a9ac7f5054e8c4650931.png)  <br>***Drop Box Data Class: Load From File*** | ![](https://manual.pvxplus.com/migration-assets/5bde2feabc56bd65f5c58c6d4d10e53bbc60de83bdcdc7dfd7c3cf50659d3614.png)  <br>***List Box Data Class: Load From File*** |

Note:  
The Load From File check box is available only when defining *Dynamic* data classes for Drop Boxes and List Boxes. For information on creating a dynamic data class, see [Dynamic Control Properties](https://manual.pvxplus.com/data-dictionary/data-classes/dynamic).

When working with Grids in the NOMADS Panel Designer, a data class can be added in **[Grid Presets Definition](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/grid-control/presets-definition#dataclasses)** by selecting the *Class* property. If adding a ***Drop Box*** or a ***List Box*** data class that is defined with ***Load From File*** functionality, at run time, the cell will be created as a *Drop Box* populated from the pre-defined data source.

*(The Load From File check box was added in PxPlus 2019.)*

The following five examples include detailed steps on how to define the ***Load From File*** functionality for Drop Box and List Box data classes, as well as how this functionality is subsequently applied when a NOMADS panel is run.

|  |  |
| --- | --- |
|  | **[Example: Load From File (Drop Box)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_db)** |
|  | **[Example: Load From File (List Box)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_lb)** |
|  | **[Example: Load From File (Other List Box Types)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_otherlb)** |
|  | **[Example: Load From File (Drop Box Class Added to Grid)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_dbgrid)** |
|  | **[Example: Load From File (List Box Class Added to Grid)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_lbgrid)** |

All examples use the **Sales Rep** table, which consists of the data elements below.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/7a45ae1539c1fe0196dfff5319fae03bd7a68be3c1141b053e6b2918421f10f2.jpg)  <br>***Sales Rep Table: Data Elements*** |

## Example: Load From File (Drop Box)

This example includes the following steps for defining the *Load From File* functionality for a Drop Box data class and viewing run-time examples of a NOMADS panel:

- **[Step 1](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step1_db)**: Create a dynamic Drop Box data class with the *Load From File* option.
- **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_db)**: Create a Drop Box control with the *Load From File* data class.
- **[Step 3](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step3_db)**: Run the panel.

To begin:

***Step 1*: Create a Drop Box Data Class with the Load From File Option**

In **[Data Class Definitions](https://manual.pvxplus.com/data-dictionary/data-classes/dropbox)** maintenance, create a Drop Box data class. Name it **SALESDB** and select the *Dynamic* check box.

On the **Display** tab, select the *Load From File* check box. Enter the *Load From File* settings below.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/15683ab18a4816937f4fa3083efa193210b61b435c5751b02632adc1fb524f84.png)  <br>***"SALESDB" Data Class with Load From File*** |

***Step 2*: Create a Drop Box Control with the Load From File Data Class**

In Step 1, ***SalesrepKey: Sales Rep Code*** was selected for the *Key*. This value will be used when populating the Drop Box.

On the NOMADS panel, create a Drop Box control with the *Load From File* data class. Name the Drop Box control **SALESCODE** and for the *Class*, enter **SALESDB**.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/178820facb03062a33d653513677336167ae455d7cbcb7cb90b307dcf0361162.jpg)  <br>***"SALESCODE" Drop Box***![](https://manual.pvxplus.com/migration-assets/9cdd21ed0d857803f5690998f71cf2b8b498eecb3fd579f883affa41a24835f3.png)![](https://manual.pvxplus.com/migration-assets/1ebc1fce052d7931d56dcfc978ff8c8cd0ad36b2b9dfd31cb011ea154b1edfb7.png)  <br>***"SALESCODE" Drop Box with Load From File Data Class "SALESDB"*** |

***Step 3*: Run the Panel**

In Step 1, the following *Load From File* settings were selected:

|  |  |  |
| --- | --- | --- |
|  | *Key* | ***SalesrepKey: Sales Rep Code*** |
|  | *Display Value* | ***Name$*** |
|  | *Include Key and Value* | ***On*** |

At run time, the Drop Box control is populated with data from the ***Sales Rep*** table. The values displayed include ***Sales Rep Code*** and ***Name$***, separated by a **:** *(colon)* and two spaces.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/943fca5d4230a055c16836ae7e1efb582204fc3b0d1c47f863e697fd3d96b5dc.jpg)  <br>***Run-Time Example: Sales Rep Code + Name*** |

Note:  
For multi-part keys that are displayed in the Drop Box values, any Hex null characters are translated to spaces.

If the *Include Key and Value* check box is ***Off***, then the values displayed will consist of ***Name$*** only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/e6d0f280d5fe1b1c1001e51b68e69ea38e862c28c94fe47cbd404dc27e284f4b.jpg)  <br>***Run-Time Example: Name Only*** |

If *Display Value* is blank, then the values displayed will consist of ***Key*** values only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/c4eea23360fce26080e588420ee760fe07aac1ea5f56264764c01315d5ab1c16.jpg)  <br>***Run-Time Example: Key Values Only*** |

These run-time examples demonstrate how changing certain settings can affect the values displayed in the Drop Box. When a record is selected, the value returned is based on the *Return Value*, which was specified as ***SalesrepKey*** for this example. This consists of the Sales Rep Code (e.g. AN).

## Example: Load From File (List Box)

This example includes the following steps for defining the *Load From File* functionality for a List Box data class and viewing run-time examples of a NOMADS panel:

- **[Step 1](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step1_lb)**: Create a dynamic List Box data class with the *Load From File* option.
- **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_lb)**: Create a List Box control with the *Load From File* data class.
- **[Step 3](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step3_lb)**: Run the panel.

To begin:

***Step 1*: Create a List Box Data Class with the Load From File Option**

In **[Data Class Definitions](https://manual.pvxplus.com/data-dictionary/data-classes/dropbox)** maintenance, create a List Box data class and for the *List Box Type*, select *Report View*. Name it **SALESLB** and select the *Dynamic* check box.

On the **Display** tab, select the *Load From File* check box. Enter the *Load From File* settings below.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/94e10525f78cb7151fe7c3d17082127ce5ea162a1862ebd4be122c0c3c201c11.png)  <br>***"SALESLB" Data Class with Load From File*** |

***Step 2*: Create a List Box Control with the Load From File Data Class**

In Step 1, ***SalesrepKey: Sales Rep Code*** was selected for the *Key*. This value will be used when populating the List Box.

On the NOMADS panel, create a List Box control with the *Load From File* data class. Name the List Box control **SALESCODE** and for the *Class*, enter **SALESLB**.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/472f160bd3108236910ebcb33f30fac749c985cf4c1eb41b2afb6c22d567af32.jpg)  <br>***"SALESCODE" List Box***![](https://manual.pvxplus.com/migration-assets/9cdd21ed0d857803f5690998f71cf2b8b498eecb3fd579f883affa41a24835f3.png)![](https://manual.pvxplus.com/migration-assets/e6f998fbe8fcec97539001b144f938b1917061867f46a33de615d86718c33c30.png)  <br>***"SALESCODE" List Box with Load From File Data Class "SALESLB"*** |

***Step 3*: Run the Panel**

In Step 1, the following *Load From File* settings were selected:

|  |  |  |
| --- | --- | --- |
|  | *Key* | ***SalesrepKey: Sales Rep Code*** |
|  | *Display Value* | ***Name$*** |
|  | *Include Key and Value* | ***On*** |

At run time, the List Box (Report View) control is populated with data from the ***Sales Rep*** table. The values displayed include ***Sales Rep Code*** and ***Name$*** in two separate columns using the column headers from the table.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/c0ab0c3222e974374781b3110cc5f5b226c25c60f5cc7c55371d998a5a983396.jpg)  <br>***Run-Time Example: Sales Rep Code + Name*** |

Note 1:  
When determining the format for Report View List Boxes, column widths are determined by taking the higher value between the data size and the header size.  
  
Note 2:  
For multi-part keys that are displayed in the List Box values, any Hex null characters are translated to spaces.

If the *Include Key and Value* check box is ***Off***, then the values displayed will consist of ***Name$*** only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/7be759dc47f26d0a68c9e39e847bb146e6bb759c11235f8a62db3250db6d35db.jpg)  <br>***Run-Time Example: Name Only*** |

If *Display Value* is blank, then the values displayed will consist of ***Key*** values only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/30e9616ac7d5aa083634e3984bcd3ad92dd46b465931a4b19010e552d13af910.jpg)  <br>***Run-Time Example: Key Values Only*** |

These run-time examples demonstrate how changing certain settings can affect the values displayed in the List Box. When a record is selected, the value returned is based on the *Return Value*, which was specified as ***SalesRepNameKey*** (this is not the primary key) for this example. This consists of the ***Name + Sales Rep Code*** and may contain Hex null characters (e.g. Andrew Newman AN). Returning a key other than the Primary key may be advantageous if it is useful to know other values that may be passed out of the key value.

## Example: Load From File (Other List Box Types)

The examples below show List Box results that were produced when the same *Load From File* selections (see **[Example: Load From File (List Box)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_lb)** were used to define new List Box data classes for other **[List Box Types](https://manual.pvxplus.com/data-dictionary/data-classes/listbox#display)** (i.e. *Standard, Formatted, List View, Tree View*).

![](https://manual.pvxplus.com/migration-assets/0db16b1521ad207b742a8ae26f2acd356a549e83a3e1a77838b24b17c060b37e.png)

Note:  
When defining List Box data classes, the List Box Type **cannot** be changed once the data class definition is saved. If the preference is to use an existing Class Name, delete the existing definition before creating a new one with the same name.

## Example: Load From File (Drop Box Class Added to Grid)

This example includes the following steps for defining the *Load From File* functionality for a Drop Box data class, adding this data class to a grid and viewing run-time examples of a NOMADS panel:

- **[Step 1](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step1_dbgrid)**: Create a dynamic Drop Box data class with the *Load From File* option.
- **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_dbgrid)**: Add this *Load From File* data class to the **Grid Presets Definition** and then specify the column, row or cell that is to contain the Drop Box to be populated.
- **[Step 3](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step3_dbgrid)**: Run the panel.

To begin:

***Step 1*** ***:*** **Create a Drop Box Data Class with the Load From File Option**

If desired, a new Drop Box data class can be created by using the steps in the **[Example: Load From File (Drop Box)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_db)**.

Since a Drop Box data class (**SALESDB**) with the *Load From File* option was previously created, it will be used for this example. Proceed to **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_dbgrid)**.

![](https://manual.pvxplus.com/migration-assets/79970f3b4fd6da1771ef43c350e01a2e707bfaaae13e0e9e12589ea440398021.png)

***Step 2*: Add this Load From File Data Class to Grid Presets Definition**

On the NOMADS panel, create a new or select an existing Grid control. In the **Grid Properties** dialog, select the **[Presets](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/grid-control/grid-properties#presets)** tab.

In the *Property* column, select *Class* from the drop-down list. Specify the desired *Column/Row* that is to contain the Drop Box to be populated. In the *Value/Expression* column, select the **SALESDB** class from the query.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/476f713d5aa3ce51b61bf8165cb023a2f6b691c3a8399d49e148f2429a5f309a.png)  <br>***Grid Presets with Load From File Data Class "SALESDB"*** |

***Step 3*** ***:* Run the Panel**

In Step 1, the following *Load From File* settings were selected:

|  |  |  |
| --- | --- | --- |
|  | *Key* | ***SalesrepKey: Sales Rep Code*** |
|  | *Display Value* | ***Name$*** |
|  | *Include Key and Value* | ***On*** |

At run time, the Drop Box is populated with data from the ***Sales Rep*** table. The values displayed include the ***Sales Rep Code*** and ***Name$***, separated by a **:** *(colon)* and two spaces.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/6d875f55eb6e80c990511883f8dfb006b915f329a80d7ed0984f1a66f392a6ce.png)  <br>***Run-Time Example: Sales Rep Code + Name*** |

If the *Include Key and Value* check box is ***Off***, then the values displayed will consist of ***Name$*** only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/7ca795eb0ef8ca9b50cab7c9730974c48bcd087fa475d79c4e2de17bc2a41aa0.png)  <br>***Run-Time Example: Name Only*** |

If the *Display Value* is blank, then the values displayed will consist of ***Key*** values only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/5b84ed52d9e79859cad31155c39c06390bcb1ced6cff6c9d491b92738fa20e17.png)  <br>***Run-Time Example: Key Values Only*** |

These run-time examples demonstrate how changing certain settings can affect the values displayed in the Drop Box. When a record is selected, the value returned is based on the *Return Value*, which was specified as ***SalesrepKey*** for this example. This consists of the Sales Rep Code (e.g. AN).

## Example: Load From File (List Box Class Added to Grid)

This example includes the following steps for defining the *Load From File* functionality for a List Box data class, adding this data class to a grid and viewing run-time examples of a NOMADS panel:

**Note:**  
When adding a **List Box** data class with *Load From File* functionality to a grid, the cell will be created as a *Drop Box* (rather than a List Box) and populated at run time from the pre-defined data source.

- **[Step 1](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step1_lbgrid)**: Create a dynamic List Box data class with the *Load From File* option.
- **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_lbgrid)**: Add this *Load From File* data class to the **Grid Presets Definition** and then specify the column, row or cell that is to contain the Drop Box to be populated.
- **[Step 3](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step3_lbgrid)**: Run the panel.

To begin:

***Step 1*** ***:*** **Create a List Box Data Class with the Load From File Option**

If desired, a new List Box data class can be created by using the steps in the **[Example: Load From File (List Box)](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#example_lb)**.

Since a List Box data class (**SALESLB**) with the *Load From File* option was previously created, it will be used for this example. Proceed to **[Step 2](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#step2_lbgrid)**.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/2805f55126fbd9a2bbbbaf37e78d560e33dd0ffc4f3fb0d6c677ea9aa3f7258d.png) |

***Step 2*: Add this Load From File Data Class to Grid Presets Definition**

On the NOMADS panel, create a new or select an existing Grid control. In the **Grid Properties** dialog, select the **[Presets](https://manual.pvxplus.com/nomads-graphical-application/creating-panel-controls/grid-control/grid-properties#presets)** tab.

In the *Property* column, select *Class* from the drop-down list. Specify the desired *Column*/*Row* that is to contain the Drop Box to be populated (see **[Note](https://manual.pvxplus.com/data-dictionary/data-classes/populate-from-data-source#note_lb)** above). In the *Value/Expression* column, select the **SALESLB** class from the query.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/32f490224413bb68eeb29de4f2d46be131b9eabcc858398acfe213139f335bc6.png)  <br>***Grid Presets with Load From File Data Class "SALESLB"*** |

***Step 3*** ***:* Run the Panel**

In Step 1, the following *Load From File* settings were selected:

|  |  |  |
| --- | --- | --- |
|  | *Key* | ***SalesrepKey: Sales Rep Code*** |
|  | *Display Value* | ***Name$*** |
|  | *Include Key and Value* | ***On*** |

At run time, the *Drop Box* is populated with data from the ***Sales Rep*** table. The values displayed include the ***Sales Rep Code*** and ***Name$***, separated by a **:** *(colon)* and two spaces.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/41c6b23f6cfe77bbfc160967ea8ffb2ee3ef7d67a7db56f6b20332b727bdcd20.png)  <br>***Run-Time Example: Sales Rep Code + Name*** |

If the *Include Key and Value* check box is ***Off***, then the values displayed will consist of ***Name$*** only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/471e86e86f2017d6eadce9b526364b408faf6116ee78c02ff2e9d3378964f767.png)  <br>***Run-Time Example: Name Only*** |

If the *Display Value* is blank, then the values displayed will consist of ***Key*** values only.

|  |  |
| --- | --- |
|  | ![](https://manual.pvxplus.com/migration-assets/9b9013d6ab90b3723f70276f903823b3675e336b79cfd62f13821f7d0291c8a8.png)  <br>***Run-Time Example: Key Values Only*** |

These run-time examples demonstrate how changing certain settings can affect the values displayed in the List Box. When a record is selected, the value returned is based on the *Return Value*, which was specified as ***SalesRepNameKey*** (this is not the primary key) for this example. This consists of the ***Name + Sales Rep Code*** and may contain Hex null characters (e.g. Andrew Newman AN). Returning a key other than the Primary key may be advantageous if it is useful to know other values that may be passed out of the key value.

## See Also

**[Extended Class Validation](https://manual.pvxplus.com/data-dictionary/data-classes/extended-validation)**
