给控件动态添加方法
新建一個窗體,添加如下方法
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!");
}
轉載于:https://www.cnblogs.com/yuankang/archive/2012/04/19/2457318.html
總結
- 上一篇: 大量用户被卡哭!微软证实并修复Win11
- 下一篇: 买吗?本田思域混动版即将上市:百公里油耗