If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Writing a Layout Control

The following steps provide an overview of how to write a new Windows layout control for Aptify:

If using the template provided by Aptify for this project, configure the template as described in Loading the Sample Code and Templates, rename the project and class, and skip to Step 9.

 

  1. Open a new Class Library project in Visual Studio.
  2. Configure the Properties for the project.
    • When assigning an assembly name for this object, use this format: [EntityName]LayoutControl (remove spaces in the entity name)For example: RentalAgreementsLayoutControl (or SampleRentalAgreementsLayoutControl, as shown in the figure below).
    • Specify a root namespace for your project.For example: Aptify.SampleApplication.MotorLoaner, as shown below.  

      Entity Object Properties
  3. Click the References tab in the Properties page and add a reference to the following Aptify objects:
    • AptifyApplication
    • AptifyExceptionManagement
    • AptifyFormTemplateControls
    • AptifyGenericDataServices
    • AptifyGenericEntity
    • AptifyGenericEntityBase
    • AptifyUtility
    • AptifyWindowsControls
    • IAptifyDataServices
    • IAptifyFormTemplateHost
    • System.Windows.Forms (this is a Microsoft .NET object)

      References to the following Microsoft Objects should already exist in the project: System, System.Data, and System.Xml. You can find the Aptify objects in your Aptify Windows application's C:\Program Files\Aptify 5.5 directory.

  4. Open the class file.
  5. Add Option Explicit On and Option Strict On at the top of the class file (as described in Use Option Explicit and Option Strict.
  6. Add Imports Aptify.Framework.WindowsControls namespace to the class file to import the Aptify Windows Controls.
  7. Define the name for your class (typically this is Public Class [Entity Name]Layout).
  8. Add Inherits FormTemplateLayout below the class name.

     Layout Control Inheritance
  9. Declare the instances of the controls from the form with which this class will interact.
    • In following figure, the RentalAgreementsLayout declares a variable for each field displayed on the Rental Agreements form. Each field has a variable that is declared as an instance of its particular Aptify Windows Control, such as an AptifyLinkBox or AptifyTextBox. 

      Declare Controls
  10. Write a FindControls method to locate the controls on the form and assign them to the variables you declared to handle events.
  11. See the source code for the RentalAgreementsLayoutControl for its implementation of FindControls, a portion of which is shown in the figure below. 

    FindControls Method Example
  12. Override the OnFormTemplateLoaded method that is called when the form has loaded.
  13. Write code to define the behavior required of the Layout Control.
    • See the source code for the Rental Agreements Layout Control for an example of how to implement control visibility.
    • The layout control implements three phases of a Rental Agreements record (Check-Out, Check-In, and Complete) and sets control visibility according to each phase. See An Example of the Effects of a Layout Control for an overview of how this control visibility translates to the user experience.
    • See the _m_lnkVehicleID_ValueChanged_ method in the Rental Agreements Layout Control's source code for an example of how to automatically populate one field (StartingMileage) when a user populates another field (VehicleID) on the form.
    • See the Aptify Software Development Kit (SDK) for information on other layout controls created for Aptify business applications, including these classes:
      • Companies: Aptify.Applications.Companies.CompaniesLayout
      • Persons: Aptify.Applications.Persons.PersonsLayout
      • Products: Aptify.Applications.ProductSetup.WindowsControls.ProductLayout
      • Orders: Aptify.Applications.OrderEntry.WindowsControls.OrdersLayout
         
  14. Build, test, and sign the assembly. See Best Practices When Writing Code for Aptify for details.
  15. Add the assembly to the Aptify Object Repository and link it to the appropriate form's top-level Form Templates record.

Copyright © 2014-2019 Aptify - Confidential and Proprietary