TreeList devexpress图标

时间:2011-01-25 13:50:51

标签: c# .net devexpress

我使用Difference类作为treelist中的数据源。然后我想根据类型差异的属性值显示与节点不同的图标。这是我的代码:

treeList1_GetStateImage(object sender, DevExpress.XtraTreeList.GetStateImageEventArgs e)
{
TreeListColumn tlColumn = treeList1.Columns["DifferenceType"];
        DifferenceTypeEnum differenceType = (DifferenceTypeEnum)e.Node.GetValue(tlColumn);
        switch (differenceType)
        {
            case DifferenceTypeEnum.Added:

                e.NodeImageIndex = 0;
                break;
            case DifferenceTypeEnum.Deleted:
                e.NodeImageIndex = 1;
                break;
            case DifferenceTypeEnum.Modified:
                e.NodeImageIndex = 2;
                break;
            default:
                throw new Exception("Difference with not specified type");
        }

我希望在选择时和未选中时都有相同的图标,这就是全部,nothiung else,但现在每次我点击一个节点NodeImageIndex被更改为0,WHen节点没有被选中,一切正常,

是的,我已经厌倦了......

感谢您的帮助

2 个答案:

答案 0 :(得分:1)

我建议你也处理GetSelectImage事件,以定义在选择某个节点时应该显示哪个图像。

答案 1 :(得分:1)

我只想知道如何根据类型的属性将指定的图标与节点连接。 Lests说我绑定了水果列表,如果水果有gaot typoe属性设置为banana,请将图像设为banana.png,如果apple然后apple.png等等:)

与此treelist连接的imageCollection已经获得了具有相应索引的图像。

相关问题