Image, SelectedImage, ExpandedImage Property

Purpose

Returns or sets a value that specifies which ListImage object in an ImageList control to use with another object.

Syntax

object.Image [= index]

object.SelectedImage[ = index]

object.ExpandedImage[ = index]

object: Node, Button, Tab

index:An integer or unique string specifying the ListImage object to use with object. The integer is the value of the Index property; the string is the value of the Key property.

Description

Before setting the Image property, you must associate an ImageList control with a Toolbar, TreeView, or TabStrip control by setting each control's ImageList property to an ImageList control.

The SelectedImage property returns or sets the index or key value of a ListImage object in an associated ImageList control; the ListImage is displayed when a Node object is selected. If this property is set to Null, the mask of the default image specified by the Image property is used.

The ExpandedImage property allows you to change the image associated with a Node object when the user double-clicks the node or when the Node object's Expanded property is set to True.

Example

Local Int m, n

Ocx ImageList iml

iml.ImageHeight = 16 : iml.ImageWidth = 16

iml.Add , "image", CreatePicture(LoadIcon(_INSTANCE, 7))

iml.Add , "selimage", CreatePicture(LoadIcon(_INSTANCE, 1))

iml.Add , "expimage", CreatePicture(LoadIcon(_INSTANCE, 9))

Ocx TreeView tv = "", 10, 10, 200, 300

tv.LineStyle = tvwRootLines

tv.Style = tvwTreelinesPlusMinusPictureText

tv.ImageList = iml

For n = 1 To 10 : Read m

If m = 0 : tv.Add , , , "Project" & n

Else : tv.Add m, tvwChild, , "Project" & n

EndIf

tv.Node(n).Image = 1

tv.Node(n).SelectedImage = 2

tv.Node(n).ExpandedImage = 3

Next n

Data 0,1,1,2,0,0,5,5,6,9

Do : Sleep : Until Me Is Nothing

See Also

Node, Button, Tab

{Created by Sjouke Hamstra; Last updated: 10/10/2014 by James Gaite}