|
25.01.2010, 17:05 | #1 |
Участник
|
kamalblogs: Adding custom images for Treenode in Dynamics Ax
Источник: http://kamalblogs.wordpress.com/2008...n-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(); try { if (_filePath) { image.loadImage(_filePath); imageNum = imagelist.add(image); imageConvert.insert(_idNo, imageNum); } } catch { warning(strfmt("@SYS85977")); } } 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. salesLineTree.setImagelist(imageList.imageList()); 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… Источник: http://kamalblogs.wordpress.com/2008...n-dynamics-ax/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|