1

I use Difference class as my datasource in treelist. Then I would like to show different icon with node according to property value of the type Difference. Here is my Code:

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");
        }

I would like to have the same icons when selected and when not selected and thats all, nothiung else, but now each time I click on a node NodeImageIndex is changed to 0, WHen nodes arent selected everything work fine,

ehh Im tired of this ...

thanks for any help

gruber
  • 28,739
  • 35
  • 124
  • 216
  • How are you creating your nodes? You can set the node image when you create each node according to whatever criteria you want (in this case, your 'DifferenceTypeEnum' values). – Bernard Jan 25 '11 at 17:45

2 Answers2

1

I would suggest that you also handle the GetSelectImage event to define which image should be shown when a certain node is selected.

DevExpress Team
  • 11,338
  • 2
  • 24
  • 23
  • But I dont want to define which image should be shown on getSelectImage. I excatly know which images should be shown in all nodes and it depends on the property of the object. I dont want to change any image when node is selected. – gruber Jan 25 '11 at 19:16
1

I just want to know how can I connect specified icon with node according to the property of the type. Lests say Im bound to the fruit list andd if fruit has gaot typoe property set to banana let the image be banana.png if apple then apple.png and so on :)

imageCollection connectied with this treelist has got these images with corresponding indexes.

gruber
  • 28,739
  • 35
  • 124
  • 216