【问题标题】:Axapta: Form lifecycle questionAxapta:表单生命周期问题
【发布时间】:2009-12-03 16:48:08
【问题描述】:
我正在尝试将图像图标手动填充到嵌套在网格中的窗口中。
在运行事件中,字段似乎还没有值。字符串控件总是返回一个空值。这段代码有更好的地方吗?在 .NET 中,我会使用数据绑定事件。 AX 中是否有等价物?
void run()
{
FormStringControl s = element.control(control::ABC_Icons_FileName);
FormWindowControl w = element.control(control::ABC_Window);
;
w.imageName(s.valueStr());
super();
}
谢谢
【问题讨论】:
标签:
forms
lifecycle
axapta
databound
【解决方案1】:
如果我正确理解您的任务,您想在每行网格中显示图像吗?那么:
-
在form.init()中创建ImageList:
imageList = new ImageList(ImageList::smallIconWidth(), ImageList::smallIconHeight();
Image image = new Image();
;
image.loadImage(filename)
imageList.add(image);
// ...
image.loadImage(filename-n)
imageList.add(image);
ImageList 必须在 ClassDEclaration 部分中声明。
将 Grid 中 Window 字段的 AutoDaclaration 属性设置为“是”。
-
在form的init()方法中为窗口字段设置ImageList:
MyWindow.imageList(imageList);
-
在您在表单上使用的表格上创建显示方法。像这样的:
display int status()
{
if(this.amount > 10)
return 5; // 5th image from image list
else
return 6;
}
-
为您的窗口控件设置属性 DataSource 和 DataMethod:
数据源 =
数据方法 = 状态
如果您需要更多示例,请查看表单 ReqTransPo。