2.4 Work with Components

Add and Move Components

You can add components from the Repository tab to a container (form, reusable part, panel etc.) either by drag and drop or by double-clicking. The Design view has to be displayed when you do this.

Drag and Drop

When you use drag and drop you select the component in the Repository tab, keep the left mouse button pressed and position the cursor where you want to place the component and then release the mouse button.

Double-Click for Speed

Double-click a component in the Repository tab to place it in the top left corner of the container that has focus in the Design view. When you double-click the next component, it is placed underneath the previous component and aligned with it.

Double-clicking is the quickest way to add several components and automatically align them.

Select a Group

To select and move a group of components:

Accomplish Common Tasks Using Popup Menus

You can access common actions for a component by right-clicking it to bring up a popup menu.  You can do this in the Outline tab or the Design view.

In this popup menu you can copy, cut or delete the component (for the Add button). You can also create a popup menu for the button or move to the DEFINE_COM statement used to create the button. The popup menu also offers a shortcut to the click and initialize events of the button. The events available in the popup menu vary according to the component.

Copy a Component

If you want to copy a form,  select its source code and copy it using the Copy command on the ribbon or the context menu. Then create a new form or visual style and paste the code in it. Copying the source is also handy if you want to store the component or send a copy of the component as a text document.

If you want to copy a component on a form, right-click it in the Design view to bring up a popup menu:

A dialog is displayed where you can specify how you want the component copied. If the component is such that it contains other components you can specify whether you want them and their event routines copied as well.

Then move the focus to the component you want to paste the copied component and paste it using either the ribbon or Ctrl + V.

Modify Default Component Behavior

Whenever you create a new form, it is modeled on the standard form (STD_FORM) component in your system. Similarly, all reusable parts are modeled on STD_PANL.

Often, it is desirable to change default behavior for all objects with the aim of enforcing site standards. STD_FORM and STD_PANL are components, just as any forms or reusable parts you create are components, and you could modify them if desired. However, STD_FORM and STD_PANL are shipped as part of a default partition definition with LANSA. When a partition is initalized, any changes you have made will be lost.

Rather than modifying the defaults, the best technique is to create your own base form and panel and to use them as the ancestor of all of the objects you create. Create a new form, and change its behavior as required. For example, you may want all forms to appear in the center of the screen by default. To do this, set the Formposition property to ScreenCenter and save the form.

When you create new forms, set the ancestor property to your default form, and the properties, events and methods that you have defined in your base form will be inherited. Inheritance is a very powerful feature of Visual LANSA. For more information, refer to Ancestor Components.