Copyright: ProtoView Development Corp. (c) 1996


numeric expression

Any expression that can be evaluated as a number. Elements of the expression can include any combination of keywords, variables, constants, and operators that result in a number.


date expression

Date variables are stored as IEEE 64-bit (8-byte) floating-point numbers that represent dates ranging from 1 January 100 to 31 December 9999 and times from 0:00:00 to 23:59:59.  Any recognizable literal date values can be assigned to Date variables.  Literal dates must be enclosed within number sign characters (#), for example, #January 1, 1993# or #1 Jan 93#.

Date variables display dates according to the short date format recognized by your computer.  Times display according to the time format (either 12- or 24-hour) recognized by your computer.

When other numeric data types are converted to Date, values to the left of the decimal represent date information while values to the right of the decimal represent time.  Midnight is 0 and midday is .5.  Negative whole numbers represent dates before 30 December 1899.


Boolean expression

An expression that evaluates to either True or False.


string expression

Any expression that evaluates to a sequence of contiguous characters. Elements of the expression can include a function that returns a string, a string literal, a string constant, a string variable, a string Variant, or a function that returns a string Variant (Var Type 8).


object expression

An expression that specifies a particular object.  The expression can include any of the object’s containers.  For example, if your application has an Application object that contains a Document object that contains a Text object, the following are valid object expressions:

Application.Document.Text

Application.Text

Document.Text

Text


constant

A named item that retains a constant value throughout the execution of a program, as opposed to a variable, whose value can change during execution.  Each host application can define its own set of constants.  Additional constants may be defined by the user with the Const statement.  Constants can be used anywhere in your code in place of actual values.  A constant may be a string or a numeric literal, another constant, or any combination that includes arithmetic or logical operators except ls or exponentiation.  For example:

Const A = “My String”


object library

A file with the .OLB extension that provides information to OLE Automation controllers (like Visual Basic) about available OLE Automation objects.  You can use the Object Browser to examine the contents of an object library to get information about the objects provided.


Object Browser

A dialog box that lets you examine the contents of an object library to get information about the objects provided.


Control Panel

A set of programs that control your system configuration.  You use Control Panel utilities to adjust hardware and software options, such as desktop colors, printer selections, date and number formats, fonts, and locale settings, such as language and system of measurement.


design time

The time during which you build an application in the development environment by adding controls, setting control or form properties, and so on.  In contrast, during run time, you interact with the application as a user would.


run time

The time when code is running. During run time, you interact with the application as a user would.


multicolumn TreeView control

A multicolumn TreeView control is a TreeView control with its data arranged in a set of columns that go across the page. As opposed to the normal style, where all the data is arranged in a single column down the page.


Properties window

A window used to display or change properties of a selected form or control at design-time. Some custom controls have customized Property windows.


bitmap

An image represented by pixels and stored as a collection of bits in which each bit corresponds to one pixel. On color systems, more than one bit corresponds to each pixel. A bitmap usually has a .BMP filename extension.


icon

A graphical representation of an object or concept commonly used to represent minimized applications in Microsoft Windows. Essentially, an icon is a bitmap with a maximum size of 32 x 32 pixels. Icons have an .ICO filename extension.


metafile

A file that stores an image as graphical objects (lines, circles, polygons) rather than as pixels. There are two types of metafiles, standard and enhanced. Standard metafiles usually have a .WMF filename extension. Enhanced metafiles usually have an .EMF filename extension. Metafiles preserve an image more accurately than pixels when the image is resized.


Empty Branch Object

An empty Branch object is a Branch object that does not have an associated TreeView control item. Methods that return Branch objects may return an empty Branch object to signify the end of a list or a search failure. You can detect an empty Branch by using the IsValid member function.


Branch Object Overview
	Branch Object
A Branch object represents a single item and all its children (if any) in a TreeView control. You may manipulate an item through the methods and properties of a Branch object and you may add or remove child items through Branch object methods.

You can access the children of an item by using the Get method, and you can add child items to a Branch object by using the Add method.


	Branches Property
The Branches property returns the list of items in a TreeView control. Read only at run time, not available at design time.

Syntax

object.Branches

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

The Branches property returns a Branch Object, through which you can manipulate items in a TreeView control.

The Branch object returned by this property is the main Branch. As such it does not correspond to a TreeView control item per se, as do all other Branches. However, you can use its methods to gain access to all other items in the TreeView control.


	Indent Property
The Indent property sets or returns the amount of space, in pixels, that each subsequent child level is indented from its parent in the TreeView control.

Syntax

object.Indent [= value]

The Indent property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A numeric expression or constant that determines the amount of space, in pixels, that each subsequent child level is indented from its parent in the TreeView control.


	Count Property
The Count property returns the total number of items in a TreeView control. Read only at run time, not available at design time.

Syntax

object.Count

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

The Count property is a read only variable at run time.


	Enabled Property
Returns or sets a value that determines whether a form or control can respond to user-generated events.

Syntax

object.Enabled [= boolean]

The Enabled property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether object can respond to user-generated events.

Settings

The settings for boolean are:

Setting	Description

True	(Default) Allows object to respond to events.

False	Prevents object from responding to events.

Remarks

The Enabled property allows forms and controls to be enabled or disabled at run time.  For example, you can disable objects that don't apply to the current state of the application.  You can also disable a control used purely for display purposes, such as a text box that provides read-only information.


	Sort Property
Returns a value indicating whether the elements of a control are automatically sorted alphabetically. Read only at run time.

Syntax

object.Sort

The object placeholder represents an object expression that evaluates to TreeView control.

Return Values

The Sort property return values are:

Setting	Description

True	List items are sorted alphabetically (case-insensitive).

False	(Default) List items aren't sorted alphabetically.

Remarks

When this property is True, Visual Basic handles almost all necessary string processing to maintain alphabetic order, including changing the index numbers for items as required by the addition or removal of items.

Note   Using the Add method to add an element to a specific location in the list may violate the sort order, and subsequent additions may not be correctly sorted.


	TabPoint Property
The TabPoint property sets or returns the location of tab stops in the TreeView control.

Syntax

object.TabPoint(index) [= value]

The TabPoint property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

index	A numeric expression or constant that specifies which tab point to set or return.

value	A numeric expression or constant specifies the tab stop location, in dialog box units, from the left side of the TreeView control.

Remarks

The TreeView control must have its UseTabStops Property set to True for this property to have any effect.

If no tab stops are specified for a control, the default tab stop is two dialog box units. If only one tab stop is specified, the list box will have tab stops separated by the distance specified by that single tab stop. If more than a single tab stop is defined, a tab stop will be set for each value specified.

A dialog box unit is a horizontal or vertical distance. One horizontal dialog box unit is equal to 0.25 of the current dialog box base-width unit. These units are computed based on the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog box base units, in pixels.


	Data Property
The Data property is a user defined value that can be kept with each item in a TreeView control. Not available at design time.

Syntax

object.Data [= value]

The Data property syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

value	A numeric expression or constant specified by the user. It is stored with the Branch object in the TreeView control.

Remarks

The Data property is user defined. Neither the TreeView control nor the Branch object use this value. You can use the Data property to associate a number (or a pointer to a data structure for languages that allow the storage and usage of pointers) with a TreeView control item.

Note:  You cannot set the Data property on the main Branch. The main Branches Data property is always set to zero.


	Level Property
The Level property indicates the level the Branch object is on in a TreeView control. Read only at run time, not available at design time.

Syntax

object.Level

The object placeholder represents an object expression that evaluates to Branch object.

Remarks

The Level property represents the hierarchical level on which the Branch object resides. A Branch object at the root leve (topmost level) will have its Level property set to 0. A child of a root item will have a Level property of 1, and so on.

Note:  The Level property on the main Branch is meaningless. The main Branches Level property is always set to zero.


	Text Property
The Text property represents the text string associated with the Branch object. Not available at design time.

Syntax

object.Text [= string]

The Text property syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

string	A string expression specifying the text that is to be associated with the Branch object.

Remarks

The value of the Text property is initially set in the Add Method. Although you can change the value of the Text property at run time, the placement of the Branch object does not change in the hierarchy even when the Sort Property is set to True. That is to say, the item is not re-sorted in the list.

Note:  The Text property on the main Branch is meaningless. The main Branches Text property is always set to a zero length (empty) string.


	IsOpen Property
The IsOpen property returns a boolean value indicating whether or not the Branch object is open. Read only at run time, not available at design time.

Syntax

object.IsOpen

The object placeholder represents an object expression that evaluates to Branch object.

Return Values

The IsOpen property return values are:

Setting	Description

True	The object is open.

False	The object is closed.

Remarks

Branch objects that are not visible are automatically closed.

Note:  The IsOpen property on the main Branch is meaningless. The main Branches IsOpen property is always returns True.


	Font Property
Returns a Font object.

Syntax

object.Font

The Font property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Remarks

Use the Font property of an object to identify a specific Font object whose properties you want to use. For example, the following code changes the Bold property setting of a Font object identified by the Font property of a TextBox object:

txtFirstName.Font.Bold = True


	hWnd Property
Returns a handle to a TreeView control. Read-only at run time, not available at design time.

Syntax

object.hWnd

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

Note  Because the value of this property can change while a program is running, never store the hWnd value in a variable.


PICS TreeView AboutBox Method
	AboutBox Method
Use the About command to find the version number and other pertinent information about PICS.


	Add Method
Adds a new item to the Branch.

Syntax

object.Add ( relationship, relative, text )

The Add method syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

relationship	A value or constant that specifies how the new item will be inserted into the list. This value can take on one of the following manifest constants:

pvtPositionInOrder	If the Sort Property is set to True, pvtPositionInOrder causes the new 	item to be inserted in sorted order in the list. If the Sort Property is set to False, the new item will be inserted at the end of the list.

The relative argument is ignored if pvtPositionInOrder is used.

pvtPositionBefore	Causes the new item to appear before the item specified in relative.

pvtPositionAfter	Causes the new item to appear after the item specified in relative.

relative	A numeric expression constant that specifies the relative item. This argument is a zero based index of the child items of the Branch object. The first child of a Branch is at index 0, the second at index 1, and so on.

text	A string expression that specifies the text of the new item.

Remarks

To remove an item from a Branch, use the remove method.


	Clear Method
Removes all the child items from a Branch.

Syntax

object.Clear

The object placeholder represents an object expression that evaluates to Branch object.

Remarks

If the object is the main Branch, then the TreeView control will be cleared of all items. Otherwise, only the children of the specified Branch will be cleared.


	Get Method
Returns a Branch object from a related Branch object.

Syntax

object.Get ( relationship, relative )

The Get method syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

relationship	A value or constant that specifies which new item will be obtained from the list. This value can take on one of the following manifest constants:

pvtGetNextSibling	Returns the next Branch object that is at the same hierarchical level in the TreeView control as this Branch. If no subsequent Branch object exists at this level, the method returns an empty Branch object.

The relative argument is ignored if GetNextSibling is used.

pvtGetPrevSibling	Returns the previous Branch object that is at the same hierarchical level in the TreeView control as this Branch. If no previous Branch object exists at this level, the method returns an empty Branch object.

The relative argument is ignored if GetPrevSibling is used.

pvtGetNextVisible	Returns the next Branch object that is visible on the TreeView control after this object. If no subsequent Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetNextVisible is used.

pvtGetPrevVisible	Returns the previous Branch object that is visible on the TreeView control before this object. If no previous Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevVisible is used.

pvtGetNextSelected	Returns the next Branch object that is selected on the TreeView control after this object. If no subsequent selected Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetNextSelected is used.

pvtGetPrevSelected	Returns the previous Branch object that is selected on the TreeView control before this object. If no previous selected Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevSelected is used.

pvtGetParent	Returns the parent Branch of this object. If the Branch object does not have a parent, the method returns an empty Branch object.

The relative argument is ignored if GetParent is used.

pvtGetNext	Returns the next Branch object in the TreeView control after this object. If no subsequent Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetNext is used.

pvtGetPrevious	Returns the previous Branch object in the TreeView control before this object. If no previous Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevious is used.

pvtGetChild	Returns a child Branch object of this object. If no child Branch object exists, the method returns an empty Branch object. The child object obtained depends on the value of the relative argument.

relative	A numeric expression constant that specifies the relative item. This argument is a zero based index of the child items of the Branch object. The first child of a Branch is at index 0, the second at index 1, and so on.

Remarks

To add an item to a Branch, use the Add Method. To remove an item from a Branch, use the Remove Method.

For a single selection TreeView control, both the GetNextSelected and GetPrevSelected arguments will return the selected Branch if a Branch is selected. If no Branch is selected, the Get method will return an an empty Branch object.


	IsValid Method
Returns boolean value indicating whether or not the Branch object is a valid Branch object.

Syntax

object.IsValid

The object placeholder represents an object expression that evaluates to Branch object.

Returns

Value	Description

True	The object is a valid Branch.

False	The object is not a valid Branch.

Remarks

Some Branch object methods will return an invalid, or empty Branch object, signifiying the end of a list or a search failure.


	Remove Method
Removes and deletes a Branch from a TreeView Control.

Syntax

object.Remove

The object placeholder represents an object expression that evaluates to Branch object.

Remarks

To add an item to a Branch, use the Add Method. To remove all child items from a Branch, use the Clear Method.


	Lock Method
Locks a Branch in a TreeView Control.

Syntax

object.Lock

The object placeholder represents an object expression that evaluates to Branch object.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.


	Unlock Method
Unlocks a Branch in a TreeView Control.

Syntax

object.Unlock

The object placeholder represents an object expression that evaluates to Branch object.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.


	IsLocked Method
Returns a boolean value indicating whether or not the Branch object is locked.

Syntax

object.IsLocked

The object placeholder represents an object expression that evaluates to Branch object.

Returns

Value	Description

True	The Branch object is locked.

False	The Branch object is not locked.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.


	Open Method
Opens the Branch object according to command argument.

Syntax

object.Open ( command )

The Open method syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

command	A value or constant that specifies how the Open method will operate on the Branch object. The command argument can take on one of the following values:

Command	Action

pvtEnsureVisible	Ensures that the Branch object is visible by opening all parent Branches as neccessary. Does not open the Branch object itself.

pvtNode	Same as EnsureVisible. In addition, causes the Branch object to open if it has child Branches and is currently closed.

pvtChildren	Same as Node. In addition, causes all immediate children of the Branch object to open.

pvtAllChildren	Same as Children. In addition, causes all children of the Branch object to open (including grandchildren, great grandchildren, etc).

Remarks

When a Branch is locked, it retains its display state (either open or closed).


	Close Method
Closes the Branch object according to command argument.

Syntax

object.Close ( command )

The Close method syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

command	A value or constant that specifies how the Close method will operate on the Branch object. The command argument can take on one of the following values:

Command	Action

Node	Causes the Branch object to close if it is not already closed.

Children	Causes all the children of the Branch object to close.

Remarks

When a Branch is locked, it retains its display state (either open or closed).


	GetNext Constant
The GetNext constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the next Branch in the TreeView control. If no next Branch exists, the method returns an empty Branch object.


	GetChild Constant
The GetParent constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return a child   Branch in the TreeView control. If the child Branch does not exist, the method returns an empty Branch object.


	Node Constant
The Node constant is used with the Open Method of a Branch Object.

This argument will cause the Branch object to open. If the Branch object is not visible at the time the Open Method is called, it is first made visible.

The Node constant is also used in the Select Method of a Branch Object.

When used with the Select Method, the argument causes the Branch Object to become selected.


	Children Constant
The Children constant is used with the Open Method of a Branch Object.

This argument will cause the immediate children of the Branch object to open. If the Branch object is not visible at the time the Open Method is called, it is first made visible.


	Appearance Property
Returns or sets the paint style of a TreeView control. Read only at run time.

Syntax

object.Appearance

The object placeholder represents an object expression that evaluates to TreeView control.

Settings

The Appearance property settings are:

Setting	Description

0	Flat.  Paints controls and forms with without visual effects.

1	(Default) 3D.  Paints controls with three-dimensional effects.

Remarks

If set to 1 at design time, the Appearance property draws the control with three-dimensional effects. Setting the Appearance property to 1 also disables the BorderStyle Property.


	BackColor Property
BackColor returns or sets the background color of an object.

ForeColor returns or sets the foreground color used to display text and graphics in an object.

Syntax

object.BackColor [= color]

object.ForeColor [= color]

The BackColor and ForeColor property syntax’s have these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

color	A value or constant that determines the background or foreground colors of an object, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme.  The settings for color are:

Setting	Description

Normal RGB colors	Colors specified by using the Color palette or by using the RGB or QBColor functions in code.

System default colors	Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser.  The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

For all forms and controls, the default settings at design time are:

BackColor set to the system default color specified by the constant vbWindowBackground.

ForeColor set to the system default color specified by the constant vbWindowText.

Remarks

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF).  The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively.  The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).  If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's the Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.

To display text in the Windows operating environment, both the text color must be solid.  If the text color you've selected isn’t displayed, the selected colors may be dithered, that is, comprised of up to three different-colored pixels.  If you choose a dithered color for the text, the nearest solid color will be substituted.


	BorderStyle Property
Returns or sets the border style for a TreeView object, read only at run time.

Syntax

object.BorderStyle

The object placeholder represents an object expression that evaluates to TreeView control.

Settings

The BorderStyle property settings for a TreeView control are:

Setting	Description

0	(Default) None.

1	Fixed Single.

Remarks

The BorderStyle property is not active unless the Appearance Property is set to 0.


	ColumnWidth Property
The ColumnWidth property sets or returns the width of an individual column in the TreeView control.

Syntax

object.ColumnWidth [= value]

The ColumnWidth property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A numeric expression or constant that determines the column width, in pixels, of an individual column in a multicolumn TreeView control.

Remarks

The ColumnWidth property only affects a multicolumn / fixed column width TreeView control. That is to say, the TreeView control must have its MultiColumn Property set to True, and its MultiColumnStyle Property set to 0 for this property to have any effect.


	CustomDefaultPicture Property
The CustomDefaultPicture property sets or returns the default picture displayed next to each item on the TreeView control.

Syntax

object.CustomDefaultPicture[= picture]

The CustomDefaultPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

picture	A string expression specifying a file containing a graphic, as described in Settings.

Settings

The settings for CustomPictureDefault are:

Setting	Description

(None)	(Default) No picture.

(Bitmap, icon, metafile)	Specifies a graphic.  You can load the graphic from the Properties window at design time.  At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

At design time, you can transfer a graphic with the Clipboard using the Copy, Cut, and Paste commands on the Edit menu.  At run time, you can use Clipboard methods such as GetData, SetData, and GetFormat with the nontext Clipboard constants vbCFBitmap, vbCFMetafile, and vbCFDIB, which are listed in the Visual Basic (VB) object library in the Object Browser.

When setting the CustomDefaultPicture property at design time, the graphic is saved and loaded with the form.  If you create an executable file, the file contains the image.

Note   At run time, the CustomDefaultPicture property can be set to any other object's Picture property, or you can assign it the graphic returned by the LoadPicture function.

The TreeView control only supports bitmap images in the CustomDefaultPicture property.

For the image to display, the EnableBitmaps Property must be set to TRUE. The way in which a custom bitmap is interpreted depends on the value of the UseStateBitmaps Property.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	CustomItemPicture Property
The CustomItemPicture property sets or returns the default picture displayed next to an item on the TreeView control.

Syntax

object.CustomItemPicture[= picture]

The CustomItemPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

picture	A string expression specifying a file containing a graphic, as described in Settings.

Settings

The settings for CustomItemPicture are:

Setting	Description

(None)	(Default) No picture.

(Bitmap, icon, metafile)	Specifies a graphic.  You can load the graphic from the Properties window at design time.  At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

At design time, you can transfer a graphic with the Clipboard using the Copy, Cut, and Paste commands on the Edit menu.  At run time, you can use Clipboard methods such as GetData, SetData, and GetFormat with the nontext Clipboard constants vbCFBitmap, vbCFMetafile, and vbCFDIB, which are listed in the Visual Basic (VB) object library in the Object Browser.

When setting the CustomItemPicture property at design time, the graphic is saved and loaded with the form.  If you create an executable file, the file contains the image.

Note   At run time, the CustomItemPicture property can be set to any other object's Picture property, or you can assign it the graphic returned by the LoadPicture function.

The TreeView control only supports bitmap images in the CustomItemPicture property.

For the image to display, the EnableBitmaps Property must be set to TRUE. The way in which a custom bitmap is interpreted depends on the value of the UseStateBitmaps Property.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	CustomLevelPicture Property
The CustomLevelPicture property sets or returns the default picture displayed next to each item on the TreeView control on a particular level.

Syntax

object.CustomLevelPicture(level) [= picture]

The CustomLevelPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

level	A numeric expression that specifies the level for which the default picture is to be set.

picture	A string expression specifying a file containing a graphic, as described in Settings.

Settings

The settings for CustomLevelPicture are:

Setting	Description

(None)	(Default) No picture.

(Bitmap, icon, metafile)	Specifies a graphic.  You can load the graphic from the Properties window at design time.  At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

At design time, you can transfer a graphic with the Clipboard using the Copy, Cut, and Paste commands on the Edit menu.  At run time, you can use Clipboard methods such as GetData, SetData, and GetFormat with the nontext Clipboard constants vbCFBitmap, vbCFMetafile, and vbCFDIB, which are listed in the Visual Basic (VB) object library in the Object Browser.

When setting the CustomLevelPicture property at design time, the graphic is saved and loaded with the form.  If you create an executable file, the file contains the image.

Note   At run time, the CustomLevelPicture property can be set to any other object's Picture property, or you can assign it the graphic returned by the LoadPicture function.

The TreeView control only supports bitmap images in the CustomLevelPicture property.

For the image to display, the EnableBitmaps Property must be set to TRUE. The way in which a custom bitmap is interpreted depends on the value of the UseStateBitmaps Property.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	StandardDefaultPicture Property
Returns or sets a value indicating the default picture that will be displayed next to an item in the TreeView control.

Syntax

object.StandardDefaultPicture [= value]

The StandardDefaultPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A value or constant that determines the default picture that will be displayed next to an item in the TreeView control, as described in Settings.

Settings

The StandardDefaultPicture property settings are:

Setting	Description

picFolders	(Default) Folder Picture.

picBoxes1	Boxes #1 Picture.

picDocument	Document Picture.

picHardDisk	Hard Disk Picture.

picProgram	Program File Picture.

picSystemFile	System File Picture.

picBoxes2	Boxes #2 Picture.

picBoxes3	Boxes #3 Picture.

picASCIIFile	ASCII File Picture.

picHelpFile	Help File Picture.

Remarks

The EnableBitmaps Property allows the TreeView control to display an image next to each item at run time.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	StandardLevelPicture Property
Returns or sets a value indicating the default picture that will be displayed next to an item in the TreeView control on a particular level.

Syntax

object.StandardLevelPicture(level) [= value]

The StandardLevelPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

level	A numeric expression that specifies the level for which the default picture is to be set.

value	A value or constant that determines the default picture that will be displayed next to an item in the TreeView control, as described in Settings.

Settings

The StandardLevelPicture property settings are:

Setting	Description

None	(Default) No Picture

picFolders	Folder Picture.

picBoxes1	Boxes #1 Picture.

picDocument	Document Picture.

picHardDisk	Hard Disk Picture.

picProgram	Program File Picture.

picSystemFile	System File Picture.

picBoxes2	Boxes #2 Picture.

picBoxes3	Boxes #3 Picture.

picASCIIFile	ASCII File Picture.

picHelpFile	Help File Picture.

Remarks

The EnableBitmaps Property allows the TreeView control to display an image next to each item at run time.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	StandardItemPicture Property
Returns or sets a value indicating the default picture that will be displayed next to a specific item in the TreeView control.

Syntax

object.StandardItemPicture [= value]

The StandardItemPicture property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A value or constant that determines the default picture that will be displayed next to an item in the TreeView control, as described in Settings.

Settings

The StandardItemPicture property settings are:

Setting	Description

None	(Default) No Picture

pvtpicFolders	Folder Picture.

pvtpicBoxes1	Boxes #1 Picture.

pvtpicDocument	Document Picture.

pvtpicHardDisk	Hard Disk Picture.

pvtpicProgram	Program File Picture.

pvtpicSystemFile	System File Picture.

pvtpicBoxes2	Boxes #2 Picture.

pvtpicBoxes3	Boxes #3 Picture.

pvtpicASCIIFile	ASCII File Picture.

pvtpicHelpFile	Help File Picture.

Remarks

The EnableBitmaps Property allows the TreeView control to display an image next to each item at run time.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	TabPointCount Property
The TabPointCount property returns the number of tab stops defined in the TreeView control. Read only at run time, not available at design time.

Syntax

object.TabPointCount

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

The TreeView control must have its UseTabStops Property set to True for this property to have any meaning.

If no tab stops are specified for a control, the default tab stop is two dialog box units. If only one tab stop is specified, the list box will have tab stops separated by the distance specified by that single tab stop. If more than a single tab stop is defined, a tab stop will be set for each value specified.

A dialog box unit is a horizontal or vertical distance. One horizontal dialog box unit is equal to 0.25 of the current dialog box base-width unit. These units are computed based on the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog box base units, in pixels.


	UseTabStops Property
Returns a value indicating whether the TreeView control recognizes and expands tab characters when drawing its strings. The default tab positions are 2 dialog units. (A dialog unit is a horizontal or vertical distance. One horizontal dialog unit is equal to one-fourth of the current dialog base width unit. The dialog base units are computed based on the height and width of the current system font. The GetDialogBaseUnits Windows function returns the current dialog base units in pixels.) Read only at run time.

Syntax

object.UseTabStops

The object placeholder represents an object expression that evaluates to TreeView control.

Return Values

The UseTabStops property return values are:

Setting	Description

True	The TreeView control recognizes and expands tab characters when drawing its strings.

False	(Default) The TreeView control does not recognize and expand tab characters when drawing its strings.


	VisibleCount Property
The VisibleCount property returns the total number of visible items in a TreeView control. Read only at run time, not available at design time.

Syntax

object.VisibleCount

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

Visible items are items whose parent items are all open, as opposed to an invisible item which has one or more of its parent items closed.


	EnableMicroBitmaps Property
Returns or sets a value that determines whether a TreeView control will display a box containing either a “+” or “-” next to each item. A box with a “+” indicates that a closed item has children. Clicking on the “+” with the mouse will cause the item to open (display it’s children in the TreeView control). A box with a “-” indicates that the item has children and is open. Clicking on the “-” will cause the item to close.

Syntax

object.EnableMicroBitmaps [= boolean]

The EnableMicroBitmaps property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether object will display a box containing either a “+” or “-” next to each item.

Settings

The settings for boolean are:

Setting	Description

True	(Default) Causes object to display a box containing either a “+” or “-” next to each item.

False	Prevents object from displaying display a box containing either a “+” or “-” next to each item.


	ForeColor Property
BackColor returns or sets the background color of an object.

ForeColor returns or sets the foreground color used to display text and graphics in an object.

Syntax

object.BackColor [= color]

object.ForeColor [= color]

The BackColor and ForeColor property syntax’s have these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

color	A value or constant that determines the background or foreground colors of an object, as described in Settings.

Settings

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme.  The settings for color are:

Setting	Description

Normal RGB colors	Colors specified by using the Color palette or by using the RGB or QBColor functions in code.

System default colors	Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser.  The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

For all forms and controls, the default settings at design time are:

BackColor set to the system default color specified by the constant vbWindowBackground.

ForeColor set to the system default color specified by the constant vbWindowText.

Remarks

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF).  The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively.  The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).  If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's the Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.

To display text in the Windows operating environment, both the text color must be solid.  If the text color you've selected isn’t displayed, the selected colors may be dithered, that is, comprised of up to three different-colored pixels.  If you choose a dithered color for the text, the nearest solid color will be substituted.


	IntegralHeight Property
Returns or sets a value indicating if the control displays partial items. Read only at run time.

Syntax

object.IntegralHeight

The object placeholder represents an object expression that evaluates to TreeView control.

Settings

The settings for IntegralHeight are:

Setting	Description

True	(Default) The TreeView control resizes itself to display only complete items.

False	The TreeView control doesn't resize itself even if the item is too tall to display completely


	MultiColumn Property
Returns or sets a value indicating if the TreeView control displays the list of items in a multicolumn fashion. Read only at run time.

Syntax

object.MultiColumn

The object placeholder represents an object expression that evaluates to TreeView control.

Settings

The settings for MultiColumn are:

Setting	Description

True	The TreeView control displays its items in a multicolumn fashion.

False	(Default) The TreeView control displays its items in the normal fashion.

Remarks

The TreeView control can display multicolumn lists in one of two modes: fixed column width mode and variable column width mode.

In the fixed column width mode (see MultiColumnStyle Property), you specify the width of each column using the ColumnWidth Property. In this mode, each column will remain a constant width no matter how the TreeView control is sized.

In the variable column width mode, you specify the number of columns to be displayed on the TreeView control by setting the NumberOfColumns Property. In this mode, the number of columns displayed on the TreeView control remains constant no matter how the TreeView control is sized.


	ClearTabStops Method
Clears all tab stops in a TreeView Control.

Syntax

object.ClearTabStops

The object placeholder represents an object expression that evaluates to TreeView control.

Remarks

To remove one tab stop from a TreeView control, use the TabPoint Property to set the tab stop to -1.


Add Method - Visual Basic Example

This example adds a number of items to a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Add (mnuAdd). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuAdd_Click()

Dim root As Branch

Dim ParentNode As Branch

Dim Child As Branch

Set root = PTreeView1.Branches

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 3")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 5")

End Sub


Clear Method - Visual Basic Example

This example clears a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Add (mnuAdd) and another that contains the command Clear(mnuClear). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuAdd_Click ()

Dim root As Branch

Dim ParentNode As Branch

Dim Child As Branch

Set root = PTreeView1.Branches

root.Clear

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 3")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4")

Set Child = ParentNode.Add(pvtPositionBefore, 0, "Child Node 5")

End Sub

Private Sub mnuClear_Click ()

Dim root As Branch

Set root = PTreeView1.Branches

root.Clear

End Sub


Get Method - Visual Basic Example

This example “walks” through the list of items in a TreeView control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Walk (mnuWalk). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuWalk_Click()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

Do While node.IsValid

    Set node = node.Get(pvtGetNext, 0)

Loop

End Sub


	IsMainBranch Method
Returns boolean value indicating whether or not the Branch object is the main Branch object.

Syntax

object.IsMainBranch

The object placeholder represents an object expression that evaluates to Branch object.

Returns

Value	Description

True	The object is the main Branch.

False	The object is not the main Branch.

Remarks

To add an item to a Branch, use the Add Method. To remove an item from a Branch, use the remove method.


IsValid Method - Visual Basic Example

This example “walks” through the list of items in a TreeView control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Walk (mnuWalk). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuWalk_Click()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

Do While node.IsValid

    Set node = node.Get(pvtGetNext, 0)

Loop

End Sub


Remove Method - Visual Basic Example

This example removes the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Remove (mnuRemove). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuRemove_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

node.Remove

End Sub


Lock Method - Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then

node.Unlock

Else

node.Lock

Endif

End Sub


Unlock Method - Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then

node.Unlock

Else

node.Lock

Endif

End Sub


IsLocked Method - Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then

node.Unlock

Else

node.Lock

Endif

End Sub


Open Method - Visual Basic Example

This example opens the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Open (mnuOpen). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuOpen_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

node.Open(pvtNode)

End Sub


Close Method - Visual Basic Example

This example closes the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Close (mnuClose). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuClose_Click()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(GetChild, 0)

node.Close(Node)

End Sub


Select Method - Visual Basic Example

This example selects the first Branch object from the list of items in a TreeView control. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Select (mnuSelect). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuSelect_Click ()

Dim root As Branch

Dim node As Branch

Set root = PTreeView1.Branches

Set node = root.Get(pvtGetChild, 0)

node.Select(pvtNode)

End Sub


	GetNextSibling Constant
The GetNextSibling constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the next Branch on the same hierarchical level. If no next Branch exists, the method returns an empty Branch object.


	GetNextVisible Constant
The GetNextVisible constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the next visible Branch in the TreeView control. If no next Branch exists, the method returns an empty Branch object.


	GetPrevSibling Constant
The GetPrevSibling constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the previous Branch on the same hierarchical level. If no next Branch exists, the method returns an empty Branch object.


	PositionAfter Constant
The PositionAfter constant is used with the Add Method of a Branch Object.

This argument causes the new item to be inserted after the relative item.


	PositionBefore Constant
The PositionBefore constant is used with the Add Method of a Branch Object.

This argument causes the new item to be inserted before the relative item.


PositionInOrder Constant
	pvtPositionInOrder Constant
The pvtPositionInOrder constant is used with the Add Method of a Branch Object.

If the Sort Property is set to True, pvtPositionInOrder causes the new item to be inserted in sorted order in the list. If the Sort Property is set to False, the new item will be inserted at the end of the list.


	GetPrevVisible Constant
The GetPrevVisible constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the previous visible Branch in the TreeView control. If no previous Branch exists, the method returns an empty Branch object.


	GetNextSelected Constant
The GetNextSelected constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the next selected Branch in the TreeView control. If no next selected Branch exists, the method returns an empty Branch object.


	GetPrevSelected Constant
The GetPrevSelected constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the previous selected Branch in the TreeView control. If no previous selected Branch exists, the method returns an empty Branch object.


	NumberOfColumns Property
The NumberOfColumns property sets or returns the number of columns displayed in the TreeView control.

Syntax

object.NumberOfColumns [= value]

The NumberOfColumns property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A numeric expression or constant specifies the number of columns displayed in a multicolumn TreeView control.

Remarks

The NumberOfColumns property only affects a multicolumn / variable column width TreeView control. That is to say, the TreeView control must have its MultiColumn Property set to True, and its MultiColumnStyle Property set to 1 for this property to have any effect.


	GetPrevious Constant
The GetPrevious constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the previous Branch in the TreeView control. If no previous Branch exists, the method returns an empty Branch object.


	GetParent Constant
The GetParent constant is used with the Get Method of a Branch Object.

This argument will cause the Get Method to return the parent  Branch in the TreeView control. If no parent Branch exists, the method returns an empty Branch object.


	SelectMode Property
Returns or sets a value indicating whether a user can make multiple selections in TreeView control and how the multiple selections can be made. Read only at run time.

Syntax

object.SelectMode

The object placeholder represents an object expression that evaluates to TreeView control.

Settings

The SelectMode property settings are:

Setting	Description

0	(Default) Multiple selection isn't allowed.

1	Simple multiple selection.  A mouse click or pressing the SPACEBAR selects or deselects an item in the list.  (Arrow keys move the focus.)

2	Extended multiple selection.  Pressing SHIFT and clicking the mouse or pressing SHIFT and one of the arrow keys (UP ARROW, DOWN ARROW, LEFT ARROW, and RIGHT ARROW) extends the selection from the previously selected item to the current item.  Pressing CTRL and clicking the mouse selects or deselects an item in the list.

Remarks

This property is only available at design time, and is read only at run time.


	MultiColumnStyle Property
Returns or sets a value indicating the style of the multicolumn display.

Syntax

object.MultiColumnStyle [= value ]

The MultiColumnStyle property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A value or constant that determines the multicolumn style, as described in Settings.

Settings

The settings for value are:

Setting	Description

0	(Default) Fixed. Specifies that the TreeView control displays its items in a fixed column width mode.

1	Variable. Specifies that the TreeView control displays its items in a variable column width mode.

Remarks

The TreeView control can display multicolumn lists in one of two modes: fixed column width mode and variable column width mode.

In the fixed column width mode, you specify the width of each column using the ColumnWidth Property. In this mode, each column will remain a constant width no matter how the TreeView control is sized.

In the variable column width mode, you specify the number of columns to be displayed on the TreeView control by setting the NumberOfColumns Property.  In this mode, the number of columns displayed on the TreeView control remains constant no matter how the TreeView control is sized.


	EnsureVisible Constant
The EnsureVisible constant is used with the Open Method of a Branch Object.

This argument will cause all parents of the Branch object to open, thus insuring that this Branch is visible.


	AllChildren Constant
The AllChildren constant is used with the Open Method of a Branch Object.

This argument will cause all the children of the Branch object to open (including grandchildren, great grandchildren, etc.). If the Branch object is not visible at the time the Open Method is called, it is first made visible.


	picFolders Constant
The picFolders constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Folders picture to display next to the item.


	picBoxes1 Constant
The picBoxes1 constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Boxes #1 picture to display next to the item.


	picDocument Constant
The picDocument constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Document picture to display next to the item.


	picProgram Constant
The picProgram constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Program picture to display next to the item.


	picASCIIFile Constant
The picASCIIFile constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the ASCII File picture to display next to the item.


	picBoxes2 Constant
The picBoxes2 constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Boxes #2 picture to display next to the item.


	picBoxes3 Constant
The picBoxes3 constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Boxes #3 picture to display next to the item.


	picHardDisk Constant
The picHardDisk constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Hard Disk picture to display next to the item.


	picHelpFile Constant
The picHelpFile constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the Help File picture to display next to the item.


	picSystemFile Constant
The picSystemFile constant is used with the StandardDefaultPicture Property and the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will cause the System File picture to display next to the item.


	FindNextExact Constant
The FindNextExact constant is used with the Find Method of the TreeView control.

This argument will find the next entry that matches the text string in the TreeView Control.


	FindPrevious Constant
The FindPrevious constant is used with the Find Method of the TreeView control.

This argument will find the previous entry that matches the partial text string in the TreeView Control.


	FindPrevious Constant
The FindPrevious constant is used with the Find Method of the TreeView control.

This argument will find the previous entry that matches the partial text string in the TreeView Control.


	FindNextSibling Constant
The FindNextSibling constant is used with the Find Method of the TreeView control.

This argument will find the next entry that matches the partial text string in the TreeView Control and that shares the same parent as the relative item.


	FindNextSiblingExact Constant
The FindNextSiblingExact constant is used with the Find Method of the TreeView control.

This argument will find the next entry that exactly matches the text string in the TreeView Control and that shares the same parent as the relative item.


	FindPreviousSiblingExact Constant
The FindPreviousSiblingExact constant is used with the Find Method of the TreeView control.

This argument will find the previous entry that exactly matches the text string in the TreeView Control and that shares the same parent as the relative item.


	FindPreviousSibling Constant
The FindPreviousSibling constant is used with the Find Method of the TreeView control.

This argument will find the previous entry that matches the partial text string in the TreeView Control and that shares the same parent as the relative item.


	FindPreviousVisible Constant
The FindPreviousVisible constant is used with the Find Method of the TreeView control.

This argument will find the previous visible entry that matches the partial text string in the TreeView Control. A visible item is an item that has no parent nodes (i.e., a root item) or whose parent nodes are all open.


	FindNextVisible Constant
The FindNextVisible constant is used with the Find Method of the TreeView control.

This argument will find the next visible entry that matches the partial text string in the TreeView Control. A visible item is an item that has no parent nodes (i.e., a root item) or whose parent nodes are all open.


	FindNextVisibleExact Constant
The FindNextVisibleExact constant is used with the Find Method of the TreeView control.

This argument will find the next visible entry that exactly matches the text string in the TreeView Control. A visible item is an item that has no parent nodes (i.e., a root item) or whose parent nodes are all open.


	FindPreviousVisibleExact Constant
The FindPreviousVisibleExact constant is used with the Find Method of the TreeView control.

This argument will find the previous visible entry that exactly matches the text string in the TreeView Control. A visible item is an item that has no parent nodes (i.e., a root item) or whose parent nodes are all open.


	GetHandle Method
The GetHandle method returns the item handle (HITEM) of the TreeView control item associated with the Branch.

Syntax

object.GetHandle

The GetHandle property syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

Remarks

The HITEM handle can be used with the hWnd Property to send messages directly to the TreeView control.


	BeforeSelChange Event
The BeforeSelChange event is fired before an item is selected.

Syntax

Private Sub object_BeforeSelChange (ByVal Node as Branch, ByVal bProcessed as boolean)

The BeforeSelChange event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is being selected.

bProcessed	A Boolean expression that specifies whether the event procedure processed the event. When the event is fired, the value of bProcessed is False. Setting the value to True will cause the TreeView control to ignore the selection change event.

Remarks

When a node is selected in the TreeView control, the TreeView control fires the BeforeSelChange event before the selection is made. The user may cancel the selection change by setting the bProcessed variable to True. If the selection change is not canceled, the TreeView control selects the item, and then fires an AfterSelChange event.


	AfterSelChange Event
The AfterSelChange event is fired before an item is selected.

Syntax

Private Sub object_AfterSelChange(ByVal Node as Branch)

The AfterSelChange event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is has been selected.

Remarks

When a node is selected in the TreeView control, the TreeView control fires the BeforeSelChange event before the selection is made. The user may cancel the selection change by setting the bProcessed variable to True. If the selection change is not canceled, the TreeView control selects the item, and then fires an AfterSelChange event.


	BeforeExpand Event
The BeforeExpand event is fired before an item is expanded (opened).

Syntax

Private Sub object_BeforeExpand (ByVal Node as Branch, ByVal bProcessed as boolean)

The BeforeExpand event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is being expanded.

bProcessed	A Boolean expression that specifies whether the event procedure processed the event. When the event is fired, the value of bProcessed is False. Setting the value to True will cause the TreeView control to ignore the expand event.

Remarks

When a node is expanded in the TreeView control, the TreeView control fires the BeforeExpand event before the node is expanded. The user may cancel the expand event by setting the bProcessed variable to True. If the expand event is not canceled, the TreeView control expands the item, and then fires an AfterExpand event.


	AfterExpand Event
The AfterExpand event is fired after an item has been expanded (opened).

Syntax

Private Sub object_ AfterExpand(ByVal Node as Branch)

The AfterExpand event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is being expanded.

Remarks

When a node is expanded in the TreeView control, the TreeView control fires the BeforeExpand event before the node is expanded. The user may cancel the expand event by setting the bProcessed variable to True. If the expand event is not canceled, the TreeView control expands the item, and then fires an AfterExpand event.


	BeforeCollapse Event
The BeforeCollapse event is fired before an item is collapsed (closed).

Syntax

Private Sub object_BeforeCollapse(ByVal Node as Branch, ByVal bProcessed as boolean)

The BeforeCollapse event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is being collapsed.

bProcessed	A Boolean expression that specifies whether the event procedure processed the event. When the event is fired, the value of bProcessed is False. Setting the value to True will cause the TreeView control to ignore the collapse event.

Remarks

When a node is collapsed in the TreeView control, the TreeView control fires the BeforeCollapse event before the node is collapsed. The user may cancel the collapse event by setting the bProcessed variable to True. If the collapse event is not canceled, the TreeView control collapses the item, and then fires an AfterCollapse event.


	AfterCollapse Event
The AfterCollapse event is fired after an item has been collapsed (closed).

Syntax

Private Sub object_AfterCollapse(ByVal Node as Branch)

The AfterCollapse event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that has been collapsed.

Remarks

When a node is collapsed in the TreeView control, the TreeView control fires the BeforeCollapse event before the node is collapsed. The user may cancel the collapse event by setting the bProcessed variable to True. If the collapse event is not canceled, the TreeView control collapses the item, and then fires an AfterCollapse event.


	LButtonDown Event
The LButtonDown event is fired when the left button of the mouse is pressed over the TreeView control.

Syntax

Private Sub object_LButtonDown(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The LButtonDown event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the LButtonDown event.

y	The y position of the mouse at the time of the LButtonDown event.


	LButtonDblClick Event
The LButtonDblClick event is fired when the left button of the mouse is double clicked over the TreeView control.

Syntax

Private Sub object_LButtonDblClick(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The LButtonDblClick event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the LButtonDblClick event.

y	The y position of the mouse at the time of the LButtonDblClick event.


	LButtonUp Event
The LButtonUp event is fired when the left button of the mouse is released over the TreeView control.

Syntax

Private Sub object_LButtonUp(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The LButtonUp event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the LButtonUp event.

y	The y position of the mouse at the time of the LButtonUp event.


	RButtonUp Event
The RButtonUp event is fired when the right button of the mouse is released over the TreeView control.

Syntax

Private Sub object_RButtonUp(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The RButtonUp event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the RButtonUp event.

y	The y position of the mouse at the time of the RButtonUp event.


	RButtonDblClick Event
The RButtonDblClick event is fired when the right button of the mouse is double clicked over the TreeView control.

Syntax

Private Sub object_RButtonDblClick(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The RButtonDblClick event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the RButtonDblClick event.

y	The y position of the mouse at the time of the RButtonDblClick event.


	RButtonDown Event
The RButtonDown event is fired when the right button of the mouse is pressed over the TreeView control.

Syntax

Private Sub object_RButtonDown(ByVal Node as Branch, ByVal x As Single, ByVal y As Single)

The LButtonDown event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.

x	The x position of the mouse at the time of the RButtonDown event.

y	The y position of the mouse at the time of the RButtonDown event.


	Select Method
Selects or deselects the Branch object according to command argument.

Syntax

object.Select ( command )

The Select method syntax has these parts:

Part	Description

object	An object expression that evaluates to a Branch object.

command	A value or constant that specifies how the Select method will operate on the Branch object. The command argument can take on one of the following values:

Command	Action

pvtNode	Causes the Branch object to be selected.

pvtUnselect	Causes the Branch object to become unselected. Not available for single selection controls.

pvtAnchor	Causes the Branch object, and all other Branch objects between this Branch and the Caret Branch, to become selected. Same as Node for single selection controls.

pvtCaret	Causes the Branch object, and all other Branch objects between this Branch and the Anchor Branch, to become selected. Same as Node for single selection controls.

Remarks

In order to be selected, a Branch object must be visible. Therefore, all selection arguments will cause the Branch object to open before the selection is made.


PICS TreeView Events

 AfterCollapse

 AfterExpand

 AfterSelChange

 BeforeCollapse

 BeforeExpand

 BeforeSelChange

 Delete

 InPlaceEditBegin

 InPlaceEditEnd

 KeyDown

 KeyPress

 KeyUp

 LButtonDblClick

 LButtonDown

 LButtonUp

 RButtonDblClick

 RButtonDown

 RButtonUp


PICS TreeView Methods

 AboutBox

 BeginInPlaceEdit

 ClearTabStops

 EndInPlaceEdit

 Find

 GetEditHWND


	EnableLines Property
Returns or sets a value that determines whether a TreeView control will display lines connecting parent items to their children.

Syntax

object.EnableLines [= boolean]

The EnableLines property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether object will display lines connecting parent items to their children.

Settings

The settings for boolean are:

Setting	Description

True	(Default) Causes object to display lines connecting parent items to their children.

False	Prevents object from displaying lines connecting parent items to their children.


	UseStateBitmaps Property
The UseStateBitmaps property sets or returns a boolean value indicating whether or not the TreeView control uses state format bitmaps.

Syntax

object.UseStateBitmaps [= boolean]

The UseStateBitmaps property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether the TreeView control interprets custom bitmaps as state format bitmaps, as described in Settings.

Settings

The UseStateBitmaps property settings are:

Setting	Description

True	(Default) The TreeView control control interprets custom bitmaps as state format bitmaps.

False	The TreeView control control interprets custom bitmaps as normal bitmaps.

Remarks

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item.

A state formatted bitmap is a bitmap that consists of three images, each placed next to each other. Only one of the three images is displayed at any given time, depending on the state of the item. The first image is displayed when the Branch object has no children, the second image is displayed when the Branch object has children and is in the open state, and the third image is displayed when the Branch object has children and is in the closed state. Each image must be the same size as the other two. Thus, only one third of the entire bitmap is displayed at any given time.


PICS TreeView Branch Methods

 Add

 Clear

 Close

 Get

 GetHandle

 IsLocked

 IsMainBranch

 IsValid

 Lock

 Open

 Remove

 Select

 Unlock


	Find Method
Searches for a specific item in a TreeView control.

Syntax

object.Find ( relationship, relative, text )

The Find method syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView object.

relationship	A value or constant that specifies how the search for the item will proceed. This value can take on one of the following manifest constants:

FindNext	Searches for the item following relative whose Text Property begins with text string.

FindNextExact	Searches for the item following relative whose Text Property exactly matches text string.

FindPrevious	Searches for the item prior to relative whose Text Property begins with text string.

FindPreviousExact	Searches for the item prior to relative whose Text Property exactly matches text string.

FindNextSibling	Searches for the item following relative that shares the same parent as relative and whose Text Property begins with text string.

FindNextSiblingExact	Searches for the item following relative that shares the same parent as relative and whose Text Property exactly matches text string.

FindPreviousSibling	Searches for the item prior to relative that shares the same parent as relative and whose Text Property begins with text string.

FindPreviousSiblingExact	Searches for the item prior to relative that shares the same parent as relative and whose Text Property exactly matches text string.

FindNextVisible	Searches for the item following relative that is visible (i.e., an item whose parents areall open) and whose Text Property begins with text string.

FindNextVisibleExact	Searches for the item following relative that is visible (i.e., an item whose parents areall open) and whose Text Property exactly matches text string.

FindPreviousVisible	Searches for the item prior to relative that is visible (i.e., an item whose parents areall open) and whose Text Property begins with text string.

FindPreviousVisibleExact	Searches for the item prior to relative that is visible (i.e., an item whose parents areall open) and whose Text Property exactly matches text string.

relative	A Branch Object that specifies the relative item.

text	A string expression that specifies the text string to search for.

Remarks

The Find method returns a Branch Object that matches the search criteria. If no item matches the search criteria, an empty Branch object is returned.

You can use the Get method to obtain a Branch object that has a specific hierarchical relationship to a given item.


	HorizontalExtent Property
Returns or sets a value that determines the logical width of a TreeView control.

Syntax

object.HorizontalExtent [= value]

The HorizontalExtent property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

value	A numeric expression that specifies the logical width of a TreeView control. The logical width is specified in pixels.

Remarks

The HorizontalExtent property specifies the logical width of a TreeView at run time.

If the logical width of the control is less than the physical width (i.e., the actual width of the control in pixels as it appears on screen), then the HorizontalExtent property has no effect. If the logical width is greater than the physical width, a horizontal scroll bar appears at the bottom of the control to allow the user to scroll the contents of the TreeView control horizontally.


PICS TreeView Branch Properties

 CustomItemPicture

 Data

 IsOpen

 Level

 StandardItemPicture

 Text


	EnableBitmaps Property
Returns or sets a value that determines whether a TreeView control will display images next to each item in the control.

Syntax

object.EnableBitmaps [= boolean]

The EnableBitmaps property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether object will display images next to each item.

Settings

The settings for boolean are:

Setting	Description

True	(Default) Causes object to display images next to each item.

False	Prevents object from displaying images next to each item.

Remarks

The EnableBitmaps property allows the TreeView control to display an image next to each item at run time. The item to be displayed depends on a number of other settings. The way in which a custom bitmap is interpreted depends on the value of the UseStateBitmaps Property.

When a custom bitmap is assigned to an item, the TreeView control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property	This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property	If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property	If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property	If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property	If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property	This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


	Delete Event
The Delete event is fired when an item is about to be deleted.

Syntax

Private Sub object_Delete(ByVal Node as Branch)

The Delete event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is about to be deleted.

Remarks

You can associate data with each item in the parameter property of a Branch. When the Branch object is about to be deleted, you can free any data structures you have allocated in the Delete Event.


PICS TreeView Properties

 AlwaysShowSelection

 Appearance Property

 AutoOpen Property

 BackColor Property

 BorderStyle Property

 Branches Property

 ColumnWidth Property

 Count Property

 CustomDefaultPicture Property

 CustomLevelPicture Property

 Enabled Property

 EnableBitmaps Property

 EnableLines Property

 EnableMicroBitmaps Property

 Font Property

 ForeColor Property

 HorizontalExtent Property

 hWnd Property

 Indent Property

 IntegralHeight Property

 MultiColumn Property

 MultiColumnStyle Property

 NumberOfColumns Property

 ProportionalScrollBars Property

 SelectMode Property

 Sort Property

 StandardDefaultPicture Property

 StandardLevelPicture Property

 TabPoint Property

 TabPointCount Property

 UseStateBitmaps Property

 UseTabStops Property

 VisibleCount Property


	FindPreviousExact Constant
The FindPreviousExact constant is used with the Find Method of the TreeView control.

This argument will find the previous entry that exactly matches the text string in the TreeView Control.


Find Method Example

This example searches the tree for the first Branch object that matches a partial string “Ar” in a TreeView control. That is to say, the Find method will find the first node in the tree that has a caption that begins with “Ar”. To try this example, create a form and place a TreeView control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Find (mnuFind). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuFind_Click ()

Dim node As Branch

Set node = PTreeView1.Find(FindNext, NULL, “Ar”)

End Sub


Add Method - Visual C++ Example
Add Method - C++ Example

This example adds a number of items to a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project.

#include “ptreedef.h”

BOOL CMyDialog::OnInitDialog()

{

CDialog::OnInitDialog();

CBranch root(m_treeview.GetBranches());

AddParent(root, "Parent 1");

AddParent(root, "Parent 2");

AddParent(root, "Parent 3");

AddParent(root, "Parent 4");

AddParent(root, "Parent 5");

return TRUE;

}

void CMyDialog::AddParent(CBranch& root, LPCTSTR szText)

{

CBranch aParent(root.Add(pvtPositionInOrder, 0, szText));

AddChild(aParent, "Child 1");

AddChild(aParent, "Child 2");

AddChild(aParent, "Child 3");

AddChild(aParent, "Child 4");

AddChild(aParent, "Child 5");

}

void CMyDialog::AddChild(CBranch& aParent, LPCTSTR szText)

{

CBranch aChild(aParent.Add(pvtPositionInOrder, 0, szText));

aChild.Add(pvtPositionInOrder, 0, "GrandChild 1");

aChild.Add(pvtPositionInOrder, 0, "GrandChild 2");

aChild.Add(pvtPositionInOrder, 0, "GrandChild 3");

aChild.Add(pvtPositionInOrder, 0, "GrandChild 4");

aChild.Add(pvtPositionInOrder, 0, "GrandChild 5");

}


TreeView Control Overview
	PICS TreeView OLE Control

The PICS TreeView OLE control is a hierarchical list box control suitable for displaying lists of items in a hierarchical manner. The TreeView control is similar to the Microsoft treeview control; however, the PICS version adds a number of important features.

To add items to the TreeView control, use the Branches property to obtain the main Branch Object, then use the Add Method of the Branch object to add items to the list. Likewise, you can use the Remove Method of the Branch object to remove items from the list. Most operations that affect the list of items in a TreeView control are done through the methods and properties of the Branch object.

New Features

The PICS TreeView control allows you to display the list of items in a multi-column fashion, using either fixed column width or fixed number of columns styles. See the MultiColumn Property for details.

In addition to multi-columns, you can display tabbed text in the TreeView control. Use the UseTabStops Property to enable tab stops for the control, and use the TabPoint Property to set tab stop positions.

Bitmaps are a special and flexible feature of the TreeView control. The TreeView control comes with a set of useful prebuilt bitmaps (Standard Pictures), or you can specify your own (Custom Pictures). You can specify a default picture (either a Standard or Custom Picture) that will be used for all items in the TreeView control. In addition, you can specify a default picture (again, either Standard or Custom) for a particular level of the list. And of course, you can specify a particular picture (either Standard or Custom) that is assigned to an individual item in the list. See the StandardDefaultPicture Property or CustomDefaultPicture Property for details.


	None Constant
The None constant is used with the StandardLevelPicture Property of a TreeView Control, and the StandardItemPicture Property of a Branch Object.

This argument will set the standard picture property to a blank picture, in effect, turning off the standard picture property.


	Anchor Constant
)}

The Anchor constant is used with the Select Method of the Branch object.

This argument will set the Branch object as the Anchor point in a mutiple or extended selection TreeView Control.


Branch Object Implementation File

#include "stdafx.h"

#include "branch.h"

#include "Picture.h"

CBranch::CBranch()

{

}	// Calls COleDispatchDriver default constructor

CBranch::CBranch(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch)

{

}

CBranch::CBranch(const CBranch& dispatchSrc) : COleDispatchDriver(dispatchSrc)

{

}

CBranch::~CBranch()

{

}

CString CBranch::GetText()

{

CString result;

GetProperty(0x1, VT_BSTR, (void*)&result);

return result;

}

void CBranch::SetText(LPCTSTR propVal)

{

SetProperty(0x1, VT_BSTR, propVal);

}

long CBranch::GetData()

{

long result;

GetProperty(0x2, VT_I4, (void*)&result);

return result;

}

void CBranch::SetData(long propVal)

{

SetProperty(0x2, VT_I4, propVal);

}

short CBranch::GetLevel()

{

short result;

GetProperty(0x3, VT_I2, (void*)&result);

return result;

}

BOOL CBranch::GetIsOpen()

{

BOOL result;

GetProperty(0x4, VT_BOOL, (void*)&result);

return result;

}

short CBranch::GetStandardItemPicture()

{

short result;

GetProperty(0x5, VT_I2, (void*)&result);

return result;

}

void CBranch::SetStandardItemPicture(short propVal)

{

SetProperty(0x5, VT_I2, propVal);

}

CPicture CBranch::GetCustomItemPicture()

{

LPDISPATCH pDispatch;

GetProperty(0x6, VT_DISPATCH, (void*)&pDispatch);

return CPicture(pDispatch);

}

void CBranch::SetCustomItemPicture(LPDISPATCH propVal)

{

SetProperty(0x6, VT_DISPATCH, propVal);

}

void CBranch::Clear()

{

InvokeHelper(0x7, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

CBranch CBranch::Add(short relationship, short relative, LPCTSTR text)

{

LPDISPATCH pDispatch;

static BYTE parms[] = VTS_I2 VTS_I2 VTS_BSTR;

InvokeHelper(0x8, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,

relationship, relative, text);

return CBranch(pDispatch);

}

CBranch CBranch::Get(short relationship, short relative)

{

LPDISPATCH pDispatch;

static BYTE parms[] = VTS_I2 VTS_I2;

InvokeHelper(0x9, DISPATCH_METHOD, VT_DISPATCH, (void*)&pDispatch, parms,

relationship, relative);

return CBranch(pDispatch);

}

void CBranch::Remove()

{

InvokeHelper(0xa, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

void CBranch::Lock()

{

InvokeHelper(0xb, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

void CBranch::Unlock()

{

InvokeHelper(0xc, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

BOOL CBranch::IsLocked()

{

BOOL	result;

InvokeHelper(0xd, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);

return result;

}

BOOL CBranch::IsValid()

{

BOOL	result;

InvokeHelper(0xe, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);

return result;

}

BOOL CBranch::IsMainBranch()

{

BOOL	result;

InvokeHelper(0xf, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);

return result;

}

void CBranch::Open(short cmd)

{

static BYTE parms[] = VTS_I2;

InvokeHelper(0x10, DISPATCH_METHOD, VT_EMPTY, NULL, parms,

cmd);

}

void CBranch::Close(short cmd)

{

static BYTE parms[] = VTS_I2;

InvokeHelper(0x11, DISPATCH_METHOD, VT_EMPTY, NULL, parms,

cmd);

}

void CBranch::Select(short cmd)

{

static BYTE parms[] = VTS_I2;

InvokeHelper(0x12, DISPATCH_METHOD, VT_EMPTY, NULL, parms,

cmd);

}

long CBranch::GetHandle()

{

long	result;

InvokeHelper(0x13, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);

return result;

}


Branch Object Header File

#ifndef __BRANCH_H__

#define __BRANCH_H__

// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

// NOTE: Do not modify the contents of this file.  If this class is regenerated by

//  Microsoft Visual C++, your modifications will be overwritten.

class CPicture;

/////////////////////////////////////////////////////////////////////////////

// CBranch wrapper class

class CBranch : public COleDispatchDriver

{

public:

CBranch();	// Calls COleDispatchDriver default constructor

CBranch(LPDISPATCH pDispatch);

CBranch(const CBranch& dispatchSrc);

~CBranch();

enum

{ pvtPositionInOrder, pvtPositionBefore, pvtPositionAfter };

enum

{

GetNextSibling = 0,

GetPrevSibling = 1,

GetNextVisible = 2,

GetPrevVisible = 3,

GetNextSelected = 4,

GetPrevSelected = 5,

GetParent = 6,

GetNext = 7,

GetPrevious = 8,

GetChild = 9

};

enum

{

EnsureVisible,

Node,

Children,

AllChildren,

Unselect,

Anchor,

Caret

};

// Attributes

public:

CString GetText();

void SetText(LPCTSTR lpszNewValue);

long GetData();

void SetData(long nNewValue);

short GetLevel();

BOOL GetIsOpen();

short GetStandardItemPicture();

void SetStandardItemPicture(short nNewValue);

CPicture GetCustomItemPicture();

void SetCustomItemPicture(LPDISPATCH newValue);

void Clear();

CBranch Add(short relationship, short relative, LPCTSTR text);

CBranch Get(short relationship, short relative);

void Remove();

void Lock();

void Unlock();

BOOL IsLocked();

BOOL IsValid();

BOOL IsMainBranch();

void Open(short cmd);

void Close(short cmd);

void Select(short cmd);

long GetHandle();

// Operations

public:

};

#endif // __BRANCH_H__


	Caret Constant
The Caret constant is used with the Select Method of the Branch object.

This argument will set the Branch object as the Caret point in a mutiple or extended selection TreeView Control.


	Unselect Constant
The Unselect constant is used with the Select Method of the Branch object.

This argument will set the Branch object as unselected in a mutiple or extended selection TreeView Control.


	FindNext Constant
The FindNext constant is used with the Find Method of the TreeView control.

This argument will find the next entry that matches the partial text string in the TreeView Control.


Error 1000: Unable to remove empty Branch

An attempt was made to remove an empty Branch object. An empty Branch can be returned by various Branch object methods. Usually, an empty Branch represents the end of a list or a failed search. You can check whether or not a Branch object is an empty Branch by using the IsValid method.


Error 1001: Unable to remove main Branch

An attempt was made to remove the main Branch object. The main Branch is returned by the Branches property of the TreeView control. The main Branch cannot be removed from the control. You can determine whether or not a Branch object is the main Branch by using the method IsMainBranch.


Error 1004: Unable to lock empty Branch

An attempt was made to lock an empty Branch object. An empty Branch can be returned by various Branch object methods. Usually, an empty Branch represents the end of a list or a failed search. You can check whether or not a Branch object is an empty Branch by using the IsValid method.


Error 1005: Unable to unlock empty Branch

An attempt was made to unlock an empty Branch object. An empty Branch can be returned by various Branch object methods. Usually, an empty Branch represents the end of a list or a failed search. You can check whether or not a Branch object is an empty Branch by using the IsValid method.


Error 1002: Unable to lock main Branch

An attempt was made to lock the main Branch object. The main Branch is returned by the Branches property of the TreeView control. The main Branch cannot be locked. You can determine whether or not a Branch object is the main Branch by using the method IsMainBranch.


Error 1003: Unable to unlock main Branch

An attempt was made to unlock the main Branch object. The main Branch is returned by the Branches property of the TreeView control. The main Branch cannot be unlocked. You can determine whether or not a Branch object is the main Branch by using the method IsMainBranch.


Error 1006: Unable to open empty Branch

An attempt was made to open an empty Branch object. An empty Branch can be returned by various Branch object methods. Usually, an empty Branch represents the end of a list or a failed search. You can check whether or not a Branch object is an empty Branch by using the IsValid method.


Error 1007: Unable to open main Branch

An attempt was made to open the main Branch object. The main Branch is returned by the Branches property of the TreeView control. The main Branch cannot be opened. You can determine whether or not a Branch object is the main Branch by using the method IsMainBranch.


Error 1008: Invalid Argument

An invalid argument was supplied to the function. Check the syntax of the function and make sure all the arguments are in range.


Error 1009: Unable to close empty Branch

An attempt was made to close an empty Branch object. An empty Branch can be returned by various Branch object methods. Usually, an empty Branch represents the end of a list or a failed search. You can check whether or not a Branch object is an empty Branch by using the IsValid method.


Error 1010: Unable to close main Branch

An attempt was made to close the main Branch object. The main Branch is returned by the Branches property of the TreeView control. The main Branch cannot be closed. You can determine whether or not a Branch object is the main Branch by using the method IsMainBranch.


	AlwaysShowSelection Property
Returns or sets the selection display state of a TreeView control.

Syntax

object.AlwaysShowSelection [= boolean]

The AlwaysShowSelection property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether the selection state remains constant when the TreeView control looses focus.

Settings

The AlwaysShowSelection property settings are:

Setting	Description

True	The selected item(s) in the TreeView control are always painted with the highlight background color.

False	(Default) The selected item(s) in the TreeView control are painted with the highlight background color only when the control has focus.

Remarks

This property should normally be set to False (the default value) to comply with Microsofts’ interface design guidelines for Windows programs.


	ProportionalScrollBars Property
The ProportionalScrollBars property sets or returns a value which specifies whether or not the TreeView controls scroll bars are sized proportionally to the contents of the control.

Syntax

object.ProportionalScrollBars [= boolean ]

The ProportionalScrollBars property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that determines whether the TreeView control displays its scroll bars proportionally sized to its contents.

Settings

The settings for boolean are:

Setting	Description

True 	(Default) The TreeView control displays its scroll bars proportionally sized to its contents.

False 	The TreeView control displays its scroll bars in the normal fashion.


Clear Method - Visual C++ Example

This example clears a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Add a button on the dialog that invokes the OnClear method when pressed.

BOOL CMyDialog::OnInitDialog()

{

CDialog::OnInitDialog();

CBranch root(m_treeview.GetBranch());

root.Clear();

AddParent(root, "Parent 1");

AddParent(root, "Parent 2");

AddParent(root, "Parent 3");

AddParent(root, "Parent 4");

AddParent(root, "Parent 5");

return TRUE;

}

void CMyDialog::AddParent(CBranch& root, LPCTSTR szText)

{

CBranch aParent(root.Add(CBranch::pvtPositionInOrder, 0, szText));

AddChild(aParent, "Child 1");

AddChild(aParent, "Child 2");

AddChild(aParent, "Child 3");

AddChild(aParent, "Child 4");

AddChild(aParent, "Child 5");

}

void CMyDialog::AddChild(CBranch& aParent, LPCTSTR szText)

{

CBranch aChild(aParent.Add(CBranch::pvtPositionInOrder, 0, szText));

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 1");

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 2");

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 3");

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 4");

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 5");

}

void CMyDialog::OnClear()

{

CBranch root(m_treeview.GetBranch());

root.Clear();

}


Close Method - Visual C++ Example

This example closes the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnClose method when pressed.

void MyDialog::OnClose()

{

CBranch root(m_treeview.GetBranch());

Cbranch node(root.Get(CBranch::GetChild, 0));

node.Close(CBranch::Node)

}


Get Method - Visual C++ Example

This example “walks” through the list of items in a TreeView control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnWalk method when pressed.

#include “ptreedef.h”

void MyDialog::OnWalk()

{

CBranch	root(m_treeview.GetBranches());

CBranch*	node

node = &root.Get(pvtGetChild, 0);

while ( node->IsValid() )

{

node = &node->Get(pvtGetNext, 0);

}

}


IsLocked Method - Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()

{

Cbranch	root(m_treeview.GetBranches());

Cbranch	node(root.Get(pvtGetChild, 0));

if ( node.IsLocked() )

node.Unlock();

else

node.Lock();

}


IsValid Method - Visual C++ Example

This example “walks” through the list of items in a TreeView control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnWalk method when pressed.

void MyDialog::OnWalk()

{

CBranch	root(m_treeview.GetBranches());

CBranch*	node

node = &root.Get(pvtGetChild, 0);

while ( node->IsValid() )

{

node = &node->Get(pvtGetNext, 0);

}

}


Lock Method - Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()

{

Cbranch	root(m_treeview.GetBranches());

Cbranch	node(root.Get(pvtGetChild, 0));

if ( node.IsLocked() )

node.Unlock();

else

node.Lock();

}


Open Method - Visual C++ Example

This example opens the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnOpen method when pressed.

void MyDialog::OnOpen()

{

CBranch root(m_treeview.GetBranches());

Cbranch node(root.Get(pvtGetChild, 0));

node.Open(pvtNode)

}


Remove Method - Visual C++ Example

This example removes the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnRemove method when pressed.

void MyDialog::OnRemove()

{

CBranch root(m_treeview.GetBranches());

Cbranch node(root.Get(pvtGetChild, 0));

node.Remove()

}


Select Method - Visual C++ Example

This example selects the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnSelect method when pressed.

void MyDialog::OnSelect()

{

CBranch root(m_treeview.GetBranches());

Cbranch node(root.Get(pvtGetChild, 0));

node.Select(pvtNode)

}


Unlock Method - Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeView control. To try this example, create a dialog and place a TreeView control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object (see Branch object Header fileand Branch object implementation file) in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()

{

Cbranch	root(m_treeview.GetBranches());

Cbranch	node(root.Get(pvtGetChild, 0));

if ( node.IsLocked() )

node.Unlock();

else

node.Lock();

}


	AutoOpen Property
Returns or sets the auto open state of the TreeView control.

Syntax

object.AutoOpen [= boolean]

The AutoOpen property syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

boolean	A Boolean expression that specifies whether the parent item will automatically open when a child is added.

Settings

The AutoOpen property settings are:

Setting	Description

True	Items of the TreeView control automatically open the first time a child item is added to the item.

False	(Default) Items of the TreeView control do not automatically open when child items are added.

Remarks

The AutoOpen property only affects an item when the first child is added to it. This property is ignored for subsequent child items. This property is also ignored if any of the items’ parent items are closed or if the item is locked.


	KeyDown Event
Fired each time a key is pressed when the TreeView object has input focus.

Syntax

Visual Basic	Private Sub Object_KeyDown([index As Integer,] KeyCode As Integer, Shift As Integer)

Visual C++	void OnKeyDownObject(short FAR* KeyCode, short Shift);

The KeyDown event syntax has these parts:

Part	Description

Object	An object expression that evaluates to TreeView object.

index	An integer that uniquely identifies a control if it's in a control array.

KeyCode	A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key).  To specify key codes, use the constants in the object library in the Object Browser.

Shift	An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2).  These bits correspond to the values 1, 2, and 4, respectively.  Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed.  For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Remarks

The object with the focus receives all keystrokes. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

•	Extended character keys such as function keys.

•	Navigation keys.

•	Combinations of keys with standard keyboard modifiers.

•	Distinguishing between the numeric keypad and regular number keys.

Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

•	The ENTER key if the form has a 3D command button control with the Default property set to True.

•	The ESC key if the form has a 3D command button control with the Cancel property set to True.

•	The TAB key.

KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the Shift argument, you can declare constants that define the bits within the argument by using constants listed in the object library in the Object Browser.  The shift constants have the following values:

Constant	Value

vbShiftMask	1

vbCtrlMask	2

vbAltMask	4

The constants act as bit masks that you can use to test for any combination of keys.  Place the constants at the procedure level or in the Declarations section of a module and use this syntax:

Const constantname = expression

You test for a condition by first assigning each result to a temporary integer variable and then comparing Shift to a bit mask.  Use the And operator with the Shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, for example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, for example:

If ShiftDown And CtrlDown Then

Note   If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events.  Use the KeyPreview property to create global keyboard-handling routines.


	KeyPress Event
Fired each time a key is pressed when the TreeView object has input focus.

Syntax

Visual Basic	Private Sub Object_KeyPress([index As Integer,] KeyAscii As Integer)

Visual C++	void OnKeyPressObject(short FAR* KeyAscii);

The KeyPress event syntax has these parts:

Part	Description

Object	An object expression that evaluates to TreeView object.

index	An integer that uniquely identifies a control if it's in a control array.

KeyAscii	An integer that returns a standard numeric ANSI keycode.  The KeyAscii argument is passed by reference; changing it sends a different character to the object.  Changing KeyAscii to 0 cancels the keystroke so the object receives no character.

Remarks

The object with the focus receives the event.  A form can receive the event only if it has no visible and enabled controls or if the KeyPreview property is set to True.  A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or one of a few special characters, and the ENTER or BACKSPACE key. Changing the value of the KeyAscii argument changes the character displayed.

You can convert the KeyAscii argument into a character by using the expression:

Chr(KeyAscii)

You can then perform string operations and translate the character back to an ANSI number that the control can interpret by using the expression:

KeyAscii = Asc(char)

Use KeyDown and KeyUp event procedures to handle any keystroke not recognized by KeyPress, such as function keys, editing keys, navigation keys, and any combinations of these with keyboard modifiers.  Unlike the KeyDown and KeyUp events, KeyPress doesn't indicate the physical state of the keyboard; instead, it passes a character.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters.  KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: keycode, which indicates the physical key (thus returning A and a as the same key), and shift, which indicates the state of shift+key and therefore returns either A or a.

If the KeyPreview property is set to True, a form receives the event before controls on the form receive the event.  Use the KeyPreview property to create global keyboard-handling routines.

Note   The ANSI number for the keyboard combination of CTRL+@ is 0.  Because Visual Basic recognizes a KeyAscii value of 0 as a zero-length string (""), avoid using CTRL+@ in your applications.


	KeyUp Event
Fired each time a key is released when the TreeView object has input focus.

Syntax

Visual Basic	Private Sub Object_KeyUp([index As Integer,] KeyCode As Integer, Shift As Integer)

Visual C++	void OnKeyUpObject(short FAR* KeyCode, short Shift);

The KeyUp event syntax has these parts:

Part	Description

Object	An object expression that evaluates to TreeView object.

index	An integer that uniquely identifies a control if it's in a control array.

KeyCode	A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key).  To specify key codes, use the constants in the object library in the Object Browser.

Shift	An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2).  These bits correspond to the values 1, 2, and 4, respectively.  Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed.  For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Remarks

The object with the focus receives all keystrokes. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

•	Extended character keys such as function keys.

•	Navigation keys.

•	Combinations of keys with standard keyboard modifiers.

•	Distinguishing between the numeric keypad and regular number keys.

Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

•	The ENTER key if the form has a 3D command button control with the Default property set to True.

•	The ESC key if the form has a 3D command button control with the Cancel property set to True.

•	The TAB key.

KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the Shift argument, you can declare constants that define the bits within the argument by using constants listed in the object library in the Object Browser.  The shift constants have the following values:

Constant	Value

vbShiftMask	1

vbCtrlMask	2

vbAltMask	4

The constants act as bit masks that you can use to test for any combination of keys.  Place the constants at the procedure level or in the Declarations section of a module and use this syntax:

Const constantname = expression

You test for a condition by first assigning each result to a temporary integer variable and then comparing Shift to a bit mask.  Use the And operator with the Shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, for example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, for example:

If ShiftDown And CtrlDown Then

Note   If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events.  Use the KeyPreview property to create global keyboard-handling routines.


	BeginInPlaceEdit Method
Allows the user to visually edit the text of the selected item in the TreeView Control.

Syntax

object.BeginInPlaceEdit

The object placeholder represents an object expression that evaluates to TreeView control.


	EndInPlaceEdit Method
Stops the user from visually editing the text of the selected item in the TreeView Control.

Syntax

object.EndInPlaceEdit

The object placeholder represents an object expression that evaluates to TreeView control.


	GetEditHWND Method
Allows the user to obtain a handle to the edit control used for visual editing in the TreeView Control.

Syntax

OLE_HANDLE myHandle = object.GetEditHWND

The object placeholder represents an object expression that evaluates to TreeView control.


	InPlaceEditBegin Event
The InPlaceEditBegin event is fired before an item is selected.

Syntax

Private Sub object_InPlaceEditBegin (ByVal Node as Branch, fAllow as boolean)

The InPlaceEditBegin event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

Node	A reference to the Branch object that is being edited.

fAllow	A Boolean expression that specifies whether the event procedure processed the event. When the event is fired, the value of fAllow is True. Setting the value to False will cause the TreeView control to not allow the selection to be edited event.

Remarks

When a node is selected in the TreeView control, then single clicked again inside the focus rectangle, the TreeView control fires the InPlaceEditBegin event before the selection is edited. The user may cancel the event by setting the fAllow variable to False. If the event is not canceled, the TreeView control enters the selected item into “edit mode”, allowing the user to edit the text.


	InPlaceEditEnd Event
The InPlaceEditEnd event is fired before an item’s text is changed from InPlaceEditing.

Syntax

Private Sub object_InPlaceEditEnd (ByVal szText as String, fAllow as boolean)

The InPlaceEditEnd event syntax has these parts:

Part	Description

object	An object expression that evaluates to a TreeView control.

szText	The next text to be assigned to the selected Branch.

fAllow	A Boolean expression that specifies whether the event procedure processed the event. When the event is fired, the value of fAllow is True. Setting the value to False will cause the TreeView control to not allow the “edit mode” of the selected item end.

Remarks

When a node is selected in the TreeView control, then single clicked again inside the focus rectangle, the TreeView control fires the InPlaceEditBegin event before the selection is edited. The user may cancel the event by setting the fAllow variable to False. If the event is not canceled, the TreeView control enters the selected item into “edit mode”, allowing the user to edit the text.

When the user has finished typing in the new text, and tries to leave the edit control, the event InPlaceEditEnd is fired, allowing the user to determine whether or not to allow “edit mode” to end.