How to do it...

To create the parameter form, follow these steps:

  1. Drag the ConWHSVehicleParameters table from the project onto the Data Sources node in the top-left pane of form designer.
  2. Name the form as per the table's name; in this case, ConWHSVehicleParameters.
  3. Select User Interface from the left-hand pane and Form from the right-hand pane.
  4. Choose to add a new item to the project.
  5. Data sources provide additional options of how this table should behave on this form. We don't want the user to be able to delete and create records, so change the following properties to No:
    • Allow Create
    • Allow Delete
    • Insert At End
    • Insert If Empty
  1. The form designer is broken into three areas: The Form pane, Design pane, and Preview/Pattern conformance pane, as shown in the following screenshot:
  1. Let's apply some basic properties for the form, which are held against the Design node, as shown here:

Property

Value

Comment

Caption

Vehicle management parameters

This is shown in the title of the form and is usually the table's name.

Data Source

ConWHSVehicleParameters

Child nodes in the form will use this as the default Data Source property.

Title Data Source

ConWHSVehicleParameters

This form will use the title field properties from the table and display them on the form.

  1. The Design node states that a pattern is not specified, which we must do. To apply the main form pattern, right-click on the Design node and choose Apply Pattern | Table of Contents.
  1. The lower pane changes to the Pattern tab and shows the pattern's required structure, as shown in the following screenshot:

We will refer to each node in the pattern structure as a pattern element and, to aid ease of design, name the controls based on the pattern element's name.

  1. This enables us to add a Tab control, so right-click on the Design node and choose New | Tab.
  2. The error is removed from the Pattern pane, but shows that we have no tab pages within the TOC Tabs (Tab) pattern element.
  3. First, rename the new control to ParameterTab, and then add a new Tab Page by right-clicking on it in the Design pane and selecting New Tab Page.
  1. The first tab is usually a general settings tab, so name this new control GeneralTabPage.
  2. Find a suitable label for General and enter that into the Label property.
  3. As we alter the design, the designer will continually check that we are conforming to the pattern. It has found the following issues with the tab page control:
  1. We must add two Group controls, one for title fields that provide help to the user, and the other for the fields we wish to show in this page.
  2. Right-click on the GeneralTabPage control and select New | Group.
Once this is done, reselect the GeneralTabPage control and note that the pattern conformance pane has changed from a red error to a yellow warning. This means that that the controls below this level have pattern conformance errors.
  1. Rename the new group control to GeneralTitleGroup.
All controls must be unique, and naming in a way that helps us navigate to the control easily will help us greatly. should we get a build error later on.
  1. The pattern conformance pane shows we must have a StaticText control for the main title, and 0 or 1 StaticText controls for a secondary title. Right-click on GeneralTitleGroup and choose New | Static Text.
  2. Rename the new StaticText control to GeneralTitleText.
  3. Create a new label for the text General parameters and enter the ID into the Text property.
  4. Reselect the GeneralTitleGroup control and check if the pattern errors are gone.
  5. Reselect GeneralTabPage, as we now have one pattern error for a missing group. Add a new Group control.
    1. The new group control knows that it must also have a pattern applied, indicated by the Pattern: <unspecified> text after the control's name. Right-click on the control and choose Apply Pattern | Fields and Field Groups.
    2. Rename the control to GeneralFields.
    3. On the form pane, expand Data Sources, ConWHSVehicleParameters, and then Field Groups.
    1. Drag the field group, Defaults, onto the GeneralFields control in the design pane, as shown in the following screenshot:
    We can manually create groups and then add the appropriate fields. However, using a field group, any new fields added to the group will get automatically added to the form, and the Label property will be set based on the field group's label.
    1. Check each node for pattern conformance errors.
    2. Finally, we will have a special task for parameter forms; to ensure that at least one record exists, click on the Methods node and choose Override | init.
    3. Create a blank line before the call to super() and enter the following line of code:
    ConWHSVehicleParameters::Find(); 
    
    We don't care about the return value in this case. We are using the fact that the Find method for Parameter tables will automatically create a record if the table is empty.
    1. Save and close the code editor and form designers.
    ..................Content has been hidden....................

    You can't read the all page of ebook, please click here login for view all page.
    Reset
    18.117.96.26