Skip to main content

Notifications

Add Form Parts to a form at runtime

In case you need to, at runtime, create form parts, this is the right article for you.

The following code should be a foundation for what you are trying to do.  In this case we are dynamically creating a formpart on the current form for every site we have in the company:

        InventSite inventSite;
        #define.TabControlName('MyControl')
        ;
        while select inventSite
        {
            var tabbedListsControl = sender.form().design().control(formControlStr(MyWorkspace, TabbedLists));
            
            var newtabPage = tabbedListsControl.addControl(FormControlType::TabPage, 
#TabControlName+inventSite.SiteId); newtabPage.caption(inventSite.SiteId); newtabPage.hideIfEmpty(false); var formBuildPartControl = newtabPage.addControlEx(classstr(FormPartControl),
#ControlName+inventSite.SiteId) as FormBuildPartControl; formBuildPartControl.widthMode(FormWidth::SizeToContent); formBuildPartControl.heightMode(FormHeight::SizeToAvailable); formBuildPartControl.targetName(menuItemDisplayStr(MyFormPart)); formBuildPartControl.parmRunMode(FormPartControlRunMode::Local); }

Each control will be called MyControl and the SiteId.

Comments

*This post is locked for comments