如何在运行时间内在窗体中添加字符串控件?

How can a string control be added in a form during run time?

我想在单击按钮的 运行 时间内在窗体上添加一个字符串控件。

到目前为止我尝试过的:

  1. 创建了一个表单
  2. 添加了run表单方法
  3. 添加了runTimeControl_validate表单方法
  4. 在表单上添加了按钮

该按钮在其点击方法中包含以下代码:

void clicked()
{
    FormBuildDesign       design = Form.design();
    FormBuildGroupControl formBuildGroupControl;
    FormStringControl     c;
    FormControlType       fC;        
    ;

    // c = addGroup.addControl(FormControlType::String, 'RunTimeControl');

    c = ButtonGroup.addControl(fC::String, 'test');
    c.label("New control");
    formBuildGroupControl = formBuildDesign.control(addGroup.id());
}

我在行 c = ButtonGroup.addControl(fC::String, 'test');

中遇到错误

Error: Enumeration doesn't exist

首先,将fC::String替换为FormControlType::String

其次,不能将字符串控件添加到按钮组(ButtonGroup 控件类型)- 而是将其添加到普通 Group

第三,为了避免标签丢失等问题,在添加控件之前添加element.lock();,在更新其标签之后添加element.unlock();是有意义的。 -忽略这个.