I have to create some controls similar to a control created as design time of the form in the Visual Designer in PDSOE.
I have label1 control on the form, and when form run I click on button to automaticaly create N copy of that control - label2, label3 ...
There is a method Controls:Clone (), but I did not understand how to work with it.
Any help would be much appreciated. Thanks!
Russian Progress User Group
Controls:Clone will create a shallow copy of the Controls array, meaning you will get a new array object but each entry of the array will still point to the existing controls. Clone will not work for what you are looking for.
You can try something like this;
// See 1 below
DEFINE VARIABLE oDesignerControl AS Infragistics.Win.Misc.UltraPanel NO-UNDO.
// See 2 below
DEFINE INPUT PARAMETER oDesignerControl AS System.Object NO-UNDO.
Some LOOP Block:
// 1. if type is known
oDesignerControl = NEW Infragistics.Win.Misc.Ultralabel().
// 2. pass oDesignerControl control as System.Object and use DYNAMIC-NEW
oDesignerControl = DYNAMIC-NEW oDesignerControl:GetType():ToString() (). // trying to remember this on top of my head if GetType() will return the derived class type name. If not use a string corresponding to the complete type name ( including namespace) of the control you are trying to create by just passing the type name as string to a method.
// Add control to the form
oDesignerControl:NAME = "<SomeName>" + STRING(i).
---- assign additional properties of oDesignerControl here like Text, Location and Size ----
Thanks for your reply! It helped me to find a solution for my task.