Tutorials - True DataControl Lite > Tutorial 3 - Using TDataLite with Memory Data |
In this tutorial you will learn how to use TDataLite with memory array data.
Start a new project.
Place the following controls on the form (Form1) as shown in the figure: a TDataLite control (TDataLite1) and a DataGrid control (DataGrid1). This time, we do not need an ADODC control as TDataLite’s data source, we will use a memory array as the data source.
Set properties as follows:
Example Title |
Copy Code
|
---|---|
TDataLite1.DataMode 1 - MemoryArray DataGrid1.DataSource TDataLite1 |
Open the TDataLite property pages dialog by clicking the right mouse button over TdataLite1 and selecting TDataLite Properties. Select the Fields property page. Since there are no predefined fields in memory array mode, you must define the fields yourself, specifying the array structure. Click the right mouse button over the fields list area, and select New Field from the menu (alternatively, you can press the New button). A new field with the default name FIELD_0 appears. Change the name to A by typing it in the Name text box. Select 2 - Integer in the Data Type combo box. Then create two more fields, B and C. Repeat the steps above, but specify different data types: Date for B andCurrency for C. Press the OK button to close the dialog and save changes.
DataGrid1 shows the contents of an array with three fields: A (Integer), B (Date) and C (Currency). Initially the grid is empty, but data may be added. If you add data and then close and re-run the program, you will notice that the data you entered has disappeared. This is because it is stored in memory. There are provisions in TDataLite to populate a memory array with data before showing it to the user, and to save the entered data. Refer to the Array property and to the OpenData event.
Note that we used a DataGrid. Of course, we could use ComponentOne TDBGrid as well, but we did it intentionally, to emphasize that TDataLite provides this additional functionality for all controls. TDataLite in memory array mode can serve as the data source for all data-bound controls.
Close the program. Congratulations, you have successfully completed Tutorial 3!