Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Oletree and Icons
Message
From
09/03/2004 07:13:24
 
 
To
08/03/2004 16:26:00
Stephen Hunt
Admit Computer Services Inc.
Farmingdale, New York, United States
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00884241
Message ID:
00884376
Views:
33
Is there a way to have icons in the tree view??

Yes. You need to populate an ImageList control on the form with the icons you want to use in the TreeView. You must populate the ImageList with all the required images before you bind it to another control (like a TreeView) because once you have done this, you can no longer delete images nor can you insert new images into the middle of its ListImages collection. You can, however, still add

You can store images in the control at design time using the ImageList properties (Right Click on the ImageList control and select "ImageListCtrl Properties") or at run time by using the Add() method of its ListImages collection. If you are adding images visually, make sure that you set the size for the images on the ‘General’ tab of its property sheet before you start to add them because once you have added images to the control, you cannot change the image size. Once you have done this, you are ready to add the images. Clicking on the ‘Insert Picture’ button brings up a dialog that allows you to select an image.

To add images to the ImageList programmatically, you can use code like this:
This.ListImages.Add( [ nIndex ], [ cKey ], oPicture )
The nIndex argument is optional and specifies the image’s order in the ListImages collection. If no index is specified, the image is added to the end of the list. The cKey argument is also optional and is used to specify a unique value used to identify the image, analogous to a primary key. The oPicture argument is required and must contain an object reference to a picture. This means that you will need to use the LOADPICTURE() function on the graphics file in order to add the image it contains to the control.

You can access the images in the ListImages collection using either the item’s Key or its Index. You need the item’s Index in order to assign an image to a Node in a TreeView or a ListItem in a ListView. However, it may not be possible to identify the correct image without using its Key. So it will not be unusual for you to use code like this to access your images after you have populated the control;
*** Find the image in the imageList
loImage = ThisForm.oImageList.Object.ListImages( <MyImageKey> )

*** And return the index
lnRetVal = loImage.Index
You must bind the ImageList to other controls using code in the Init() of your form. If you try to bind the ImageList in the Init() of the TreeView or ListView that needs it, you run the risk of throwing an error because the ImageList may not be instantiated yet. If you bind the imageList in the Form’s Init() you can be certain that both controls have been instantiated. This line of code is all it takes:
Thisform.oTree.ImageList = Thisform.oImageList.Object
Previous
Reply
Map
View

Click here to load this message in the networking platform