Compartir a través de


Fill a List with Values from Different Sources Sample

File: ...\Samples\Solution\Controls\Lists\Multdat1.scx

This sample demonstrates setting the RowSourceType of a list box at run time to a value, an alias, a SQL statement, a query (.qpr), an array, fields in a table, files in a directory, and the structure of a table.

The combo box on the form contains all the possible RowSourceTypes of a list (except for 9 - popup, which is included for backward compatibility). The code associated with the InteractiveChange event sets the new RowSourceType and RowSource properties for the list.

When you change both the RowSourceType and RowSource of a list box at run time, you need to do the following:

  1. Set the RowSourceType to 0.

  2. Set the RowSource to the new source.

  3. Set the RowSourceType to the new type.

If you don't follow this order, the existing RowSource and RowSourceType settings could conflict after one new value is set and before the corresponding value is set.

See Also

Tasks

Add Items Interactively to a List Box Sample

Display Multiple Columns in a List Box Sample

Display Pictures in a List Sample

Move Items Between List Boxes Sample

Multiselect Items in a List Box Sample

Open Multiple Files Interactively Sample

Sort List Box Items Sample

Treeview/Listbox Drag and Drop Sample

Other Resources

Controls Solution Samples