Using the SmartTabPageControlPlugin to create parent/child Forms
The Consultingwerk.BusinessEntityDesigner.Plugins.SmartTabPageControlPlugin plugin can be activated for the Business Entity Designer.
This Plugin supports the generation of User Controls for Tab Pages similar to the SmartWindowForm generator plugin. The SmartTabFolderForm acts as a visual base class for the Form.
Base classes overview:
Class Name | Description |
---|---|
Consultingwerk.SmartComponents.BaseForms.TabFolder.SmartTabFolderForm | Visual Base Class for Tab Folder Forms |
Consultingwerk.SmartComponents.BaseForms.TabFolder.SmartTabFolderPage | Base Class for User Controls for Tab Pages |
Consultingwerk.SmartComponents.BaseForms.TabFolder.ISmartTabFolderPage | Interface for User Contrlos for Tab Pages |
Sample code for a Form inheriting from the SmartTabFolderForm
Form Constructor
CONSTRUCTOR PUBLIC OrderOrderLineForm (): DEFINE VARIABLE oTabPage AS ISmartTabFolderPage NO-UNDO . SUPER(). InitializeComponent(). &IF NOT PROVERSION BEGINS "10.2":U AND NOT PROVERSION BEGINS "11.0" &THEN THIS-OBJECT:ComponentsCollection:Add (THIS-OBJECT:components). &ENDIF /* Create Order Tab Page with no external DataSource */ oTabPage = THIS-OBJECT:CreateTabPage (NEW OrderTabPageControl (), "Order", "order", ?) . /* Create Order Line Tab Page linked from the eOrder Adapter on the order page */ oTabPage = THIS-OBJECT:CreateTabPage (NEW OrderLineTabPageControl (), "Order Lines", "orderlines", THIS-OBJECT:GetSmartTabFolderPage ("order"):SmartDataSources:GetItem ("eOrder")) . CATCH e AS Progress.Lang.Error: UNDO, THROW e. END CATCH. END CONSTRUCTOR.
The code does the following:
- Creates an instance of the OrderTabPageControl on a new Tab labelled "Order" with the key "order".
- Creates an instance of the OrderLineTabPageControl on a new Tab labelled "Order Lines" with the key "orderlines".
- Passes the "eOrder" Business Entity Adapter from within the "order" Tab Page Control to the new Control as an external Data Source
OnShown event method
The following override for the OnShown event method in the sample OrderOrderLineForm retrieves data in the "eOrder" Business Entity Adapter on the "order" tab.
/*------------------------------------------------------------------------------ Purpose: Raises the Shown event Notes: @param e The System.EventArgs with the data for this event ------------------------------------------------------------------------------*/ METHOD PROTECTED OVERRIDE VOID OnShown (e AS System.EventArgs): SUPER:OnShown (e) . PROCESS EVENTS . THIS-OBJECT:GetSmartTabFolderPage ("order"):SmartDataSources:GetItem ("eOrder"):RetrieveData() . END METHOD.
Sample code for a Tab Page User Control
InitializeSmartTabFolderPage method
The following sample code from the OrderLineTabPageControl setup up links. Most of the code is part of the template for the SmartTabFolderPage Controls.
In addition, the ForeignFields property of the smartBusinessEntityAdapter1 instance is assigned (which could also be done in the Visual Designer).
/*------------------------------------------------------------------------------ Purpose: Initializes the SmartTabFolderPage Notes: Invoked by the SmartFramesetForm when the SmartFramesetPage was added to the TabFolder. Customize this method to setup Smart... link properites etc. @param poDataSource The reference to the SmartDataSource passed from the Form for cross-tab Data links @param poTableIOSource The reference to the SmartTableIOSource (Ribbon/Toolbar) passed from the Form @param poNavigationSource The reference to the SmartTableIOSource (Ribbon/Toolbar) passed from the Form ------------------------------------------------------------------------------*/ METHOD OVERRIDE PUBLIC VOID InitializeSmartTabFolderPage (poDataSource AS Consultingwerk.SmartComponents.Interfaces.ISmartDataSource, poTableIOSource AS Consultingwerk.SmartComponents.Interfaces.ISmartTableIOSource, poNavigationSource AS Consultingwerk.SmartComponents.Interfaces.ISmartNavigationSource ): IF VALID-OBJECT (poDataSource) THEN DO: smartBusinessEntityAdapter1:ForeignFields = "ordernum,ordernum" . smartBusinessEntityAdapter1:SmartDataSource = poDataSource . END. orderLineViewerControl1:SmartTableIOSource = poTableIOSource . smartBusinessEntityAdapter1:SmartNavigationSource = poNavigationSource . SUPER:InitializeSmartTabFolderPage (poDataSource, poTableIOSource, poNavigationSource) . END METHOD.
Adding multiple Tab Page Controls to the same single Tab Page
In the below sample CustomerTabPageControl and OrderTabPageControl are added on new pages.
The ItemTabPageControl is then added to the same tab page as the orders (specified by the key "order") using the AddToTabPage method.
oTabPage = THIS-OBJECT:CreateTabPage (NEW CustomerTabPageControl (), "Customer", "customer", ?) . oTabPage = THIS-OBJECT:CreateTabPage (NEW OrderTabPageControl (), "Orders", "order", oFramesetPage:SmartDataSources:GetItem ("eCustomer")) . oTabPage = THIS-OBJECT:AddToTabPage (oTabPage, /* The Order Tab Control */ NEW ItemTabPageControl (), "order", "item", oTabPage:SmartDataSources:GetItem ("eOrderLine")) .