Home > Uncategorized > Adding custom images for Treenode in Dynamics Ax

Adding custom images for Treenode in Dynamics Ax


Tree node and Icons for tree nodes are inseparable. Right icons can make your tree look lot different.. Here is one tweak for getting the difference.

This article deals with displaying external images as tree node icons.

Images used in Treenode should be passed as Imagelist. Ax has set a predefined set of classes starting with ImageListAppl that helps to manage different sorts of ImageLists. ImageListAppl is the base classes of all such classes.

The most appropriate way to enable a strong support for external images in tree node would be through modifying the ImageListAppl class to load external images. (Currently they can load only resource numbers). The following code below when added to the base class helps you load images externally or through resource nodes.

public void addImage(int _idNo, FilePath _filePath)
    int imageNum;
    Image image = new Image();
        if (_filePath)
            imageNum = imagelist.add(image);
            imageConvert.insert(_idNo, imageNum);

Now let’s see the usage of the method we added. Take a class like ImageListAppl_Sales for example. Override the build method and implement in the way as you seen below.

this.I4C_addImage(#ImageNewPic, SysResource::getImagePath('myimage')); 

Every Image loaded has to be identified through some resource numbers. Generally it is better if the new resource number you assign is greater than the system defined resource number.To identify the Highest resource number always refer to the  “SysImageResources” form. (4.0 users you can use the Tutorial_resources form).

Two things to note from the above line of code.

-> The new Resource numbers has to be defined as a macro in a new macro node or to an existing macro node like resappl (it contains the standard resource number).

-> In the above example i have used an image from the resource node, you can also use an external image which is stored in the computer. (Resource node is preferred, coz it is easy to distribute)

To use this image all you need to do is just load the same Image list class with your tree control and then just refer to the new resource number for the image that you wanted to display.

SysFormTreeControl::addTreeItem(salesLineTree, displaystring, 0, 0, #myImage);

That’s what it takes to our new image to the tree node. So now you can widen your image space for tree icons with all kind of images you like…

Keep reading… 🙂

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: