The property editor
Prev | Chapter 6. Forms | Next

## The property editor

We will first change the properties of the label. Click on the Label object in the Form window and click on the "Data" tab in the Property Editor window if it is not already selected. Enter the text "Author" into the entry field to the right of "Label". This text will be displayed on the form.

Now we need to provide a link from the lineeditfield object to a datasource in your database from where the data will be extracted and displayed. Click on the lineditfield and then click on the "Data" tab in the Property Editor window. Click on the button marked "..." to the right of the Datasource field and select the datasource "based on table authors" (at the top of the displayed formdatasource dialog). The other fields are not of interest at this time. Click the "Add" button. Now you have linked the form field to a column in your database.

Figure 6.3. The form datasource dialog(1)

### Important

You can also use a graphical interface for defining the datasources. Click

Select the newly created datasource in the datasource field (the value should be "authors(0)") and the column "name" in the column field in the Property Editor window.

Figure 6.4. The property editor

Now let's try to browse your data in the database. Click on the "view mode" button on the form window. You can now see the name of the first author in our list, namely Goethe. Currently you can edit this field but you can't browse the author's catalogue of literature. There is a rowselector at the bottom of the form, but it is currently inactive. To activate this button we change the data properties of the form. Change back to design mode (click "design mode" button). To show the form's properties instead of the properties of an object on the form we need to make the form the active object. To do this, click on an open space on the form, avoiding all the objects on the form. The property editor now shows the properties of the form itself. Change the datasource field to "authors (0)" and revert back to "view mode". Now you can browse the whole datasource.

The next step in our objective is to display all the literature that the selected author, Goethe (or any other author), has written. To do this switch to design mode and place a gridfield object on the form. In order to make use of the selected gridfield you have to create a new datasource based on the "literature" table. --- But after clicking on the "..." button in the Property Editor window, stop! --- We only want to see the books of the selected author so there is more work to do before you push the "add" button.

The "literature" table depends on the "authors" table, i.e. any author in the "literature" table must exist in the "authors" table. So we select the already defined datasource "authors" in the "depending on" field (ignore the number in the brackets, it is a unique number for each datasource in a form). We have to tell the system how the datasources are connected, i.e. which columns are linked to each other. In the master datasource ( authors(0) ) it is the field "author_id" and in the actual datasource table (literature) it is the field "author". Select both fields and press the button with the two arrows. The linked columns names are now displayed in the listbox on the right. Finally, click the "Add" button.

Figure 6.5. The form datasource dialog(2)

Let's have a brief look at the remaining fields in the formdatasource dialog. The sorting field allows you to sort the datasource. It has the same syntax as the "ORDER BY" syntax of SQL-statements. If you want, for example, to display the literature in ascending alphabetical order just add the field name "title" into the "sorting" field. If you want a descending order add "title DESC".

If the "is readonly?" field is checked, no values of this datasource can be changed in the form. A datasource that is already readonly (e.g. all queries) will remain readonly, even if this field is not checked.

The filter field allows you to display rows of the datasource if certain conditions are met. It has the same syntax as the "WHERE" syntax of SQL-statements.

Finally, let's create a button on our form. We will define it as a "Close" button so we can close the current form when clicked. First of all we have to store the form. This can be done in two ways, either press the save button (the one with the disk) on the horizontal toolbar or click the right mouse button in "design mode" and select "Save form". When saved, create a button and change the label to "&Close". If you have selected the button object, the Property Editor will be displaying the "Action" tab. Select the action "Close form" and select the name of the form to close in the object field. Now let's test it.

Prev | Up | Next
Chapter 6. Forms | Home | Defining grid columns