给控件动态添加方法

新建一个窗体,添加如下方法

public void init()
{
FormBuildStringControl formStringControl;
FormBuildButtonControl formButtonControl;
FormBuildGroupControl formGroupControl;

;

// Adding a group
formGroupControl = this.form().addControl(FormControlType::Group, "MyGroup");
formGroupControl.caption("It's my group!");

// Adding a string to a group
formStringControl = formGroupControl.addControl(FormControlType::String,"DynamicStringControl");
formStringControl.label("Dynamic string control");


// Adding another string to the group using the same name. This will use the same event method as the
// first "DynamicStringControl"
formStringControl = formGroupControl.addControl(FormControlType::String, "DynamicStringControl");
formStringControl.label("Dynamic string control2");

formButtonControl = this.form().addControl(FormControlType::Button,"DynamicButtonControl");
formButtonControl.text("Dynamic button");

this.controlMethodOverload(true);

 

super();
}

 

boolean DynamicStringControl_Modified()
{
FormStringControl control = element.controlCallingMethod();
;

info (strFmt("Modified dynamic control %1 to %2", int2str(control.id()), control.text()));
return true;
}

 

void DynamicButtonControl_Clicked()
{
;

info ("Dynamic button clicked!");
}

posted @ 2012-04-19 16:32  K小子  阅读(183)  评论(0)    收藏  举报