Axapta:图像更改后更新 FormTreeControl

发布于 2024-08-14 00:52:06 字数 446 浏览 4 评论 0原文

在我的其他方法(数据、文本等)中,setItem 方法可以很好地显示对树项所做的更改。但是,在更改项目的图标后调用 setItem 似乎没有任何效果。更新树项目以便出现新图标的最佳方法是什么?

谢谢

public void modified()
{
    FormTreeItem workingItem;
    ;
    super();

    //find the current item
    workingItem = FormTreeControl.getItem(FormTreeControl.getSelection());
    //update the value
    workingItem.Image(1);
    //update the item in the list
    FormTreeControl.setItem(workingItem);

}

In my other methods (data, text, etc.) the setItem method works fine to display changes made to a tree item. However, calling setItem after changing an item's icon doesn't seem to have any effect. What is the best way to update the tree item so the new icon appears?

Thanks

public void modified()
{
    FormTreeItem workingItem;
    ;
    super();

    //find the current item
    workingItem = FormTreeControl.getItem(FormTreeControl.getSelection());
    //update the value
    workingItem.Image(1);
    //update the item in the list
    FormTreeControl.setItem(workingItem);

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森罗 2024-08-21 00:52:06

在这里发现了几个问题:
1. 从未找到有效更新树项上图标的方法。
2. 发现如果您尝试从数据源方法添加/删除某些树控件对象未初始化,因此删除项目会引发“对象未初始化”错误。

已修复:
1. 创建一个新项目(旧项目的addAfterIdx)。
2. 删除旧项目。
3. 选择新项目。
3. 将方法从数据源移至实际的表单控件。

这是对我有用的代码:

public boolean modified()
{
    boolean ret;
    FormTreeItem workingItem = FormTreeControl.getItem(currentEditingIdx);
    TreeItemIdx newItemIdx;
    ;
    ret = super();

    //create a new item
    newItemIdx = SysFormTreeControl::addTreeItem(FormTreeControl, workingItem.text(), FormTreeControl.getParent(workingItem.idx()), workingItem.data(), element.imageIdx(ABC_Icon.text()));
    //delete the old item
    FormTreeControl.delete(currentEditingIdx);
    //select the new item
    FormTreeControl.selectionChanged(FormTreeControl.getItem(FormTreeControl.getRoot()), FormTreeControl.getItem(newItemIdx), FormTreeSelect::Unknown);

    return ret;
}

Found a couple of issues here:
1. Never found a way to update the icon on a tree item effectively.
2. Found out some of the tree control objects aren't initialized if you try to add/delete from a datasource method, so deleting items throws Object Not Initialized errors.

Fixed it by:
1. Create a new item (addAfterIdx of the old item).
2. Delete the old item.
3. Select the new item.
3. Move the method from the datasource to the actual form control.

Here's the code that worked for me:

public boolean modified()
{
    boolean ret;
    FormTreeItem workingItem = FormTreeControl.getItem(currentEditingIdx);
    TreeItemIdx newItemIdx;
    ;
    ret = super();

    //create a new item
    newItemIdx = SysFormTreeControl::addTreeItem(FormTreeControl, workingItem.text(), FormTreeControl.getParent(workingItem.idx()), workingItem.data(), element.imageIdx(ABC_Icon.text()));
    //delete the old item
    FormTreeControl.delete(currentEditingIdx);
    //select the new item
    FormTreeControl.selectionChanged(FormTreeControl.getItem(FormTreeControl.getRoot()), FormTreeControl.getItem(newItemIdx), FormTreeSelect::Unknown);

    return ret;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文