A Branch object represents a single item and all its children (if any) in a TreeViewX 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.
To add items to the TreeViewX 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 TreeViewX control are done through the methods and properties of the Branch object.
The ProtoView TreeViewX Branch object supports the following properties:
CustomItemPicture | IsOpen | StandardItemPicture |
The CustomItemPicture property sets or returns the default picture displayed next to an item on the TreeViewX control.
Syntax
Visual Basic
object.CustomItemPicture = picture
picture = object.CustomItemPicture
Visual C++
object.SetCustomItemPicture(picture);
picture = object.GetCustomItemPicture( );
Delphi
object.CustomItemPicture := picture;
picture:= object.CustomItemPicture;
The CustomItemPicture property syntax has these parts:
Part | Description |
object | A Branch object. |
picture | A picture object which contains a graphic to assign as described in Settings. |
Settings
The settings for picture 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
Please see the Remarks for TreeViewX images.
The Data property is a user defined value that can be kept with each item in a TreeViewX control. Not available at design time.
Syntax
Visual Basic
object.Data = value
value = object.Data
Visual C++
object.SetData(value);
value = object.GetData( );
Delphi
object.Data:= value;
value:= object.Data;
The Data property syntax has these parts:
Part | Description |
object | A Branch object. |
value | A long integer specified by the user as a value or a pointer to data. It is stored with the Branch object in the TreeViewX control. |
Remarks
The Data property is user defined. Neither the TreeViewX 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 TreeViewX control item.
Note: You cannot set the Data property on the main Branch. The main Branches Data property is always set to zero.
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
Visual Basic
boolean = object.IsOpen
Visual C++
boolean = object.GetIsOpen( );
Delphi
boolean := object.IsOpen;
Part | Description |
object | A Branch object. |
boolean | A Boolean expressionK which returns whether the Branch object is open. |
Settings
The settings for boolean 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.
The Level property indicates the level the Branch object is on in a TreeViewX control. Read only at run time, not available at design time.
Syntax
Visual Basic
object.Level = value
value = object.Level
Visual C++
object.SetLevel(value);
value = object.GetLevel( );
Delphi
object.Level:= value;
lue:= object.Level;
Part | Description |
object | A Branch object. |
value | A short integer which returns the level the Branch item is located on. |
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.
Returns or sets a value indicating the default picture that will be displayed next to a specific item in the TreeViewX control.
Syntax
Visual Basic
object. StandardItemPicture = value
value = object. StandardItemPicture
Visual C++
object.SetStandardItemPicture(value);
value = object.GetStandardItemPicture( );
Delphi
object. StandardItemPicture := value;
value:= object. StandardItemPicture;
The StandardItemPicture property syntax has these parts:
Part | Description |
object | A Branch object. |
value | A constant that determines the default picture that will be displayed next to an item in the TreeViewX control, as described in Settings. |
Settings
The settings for value are:
Setting | Description |
pvtNone | No picture. |
pvtpicFolders | (Default) 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
Please see the Remarks for TreeViewX images.
The Text property represents the text string associated with the Branch object. Not available at design time.
Syntax
Visual Basic
object.Text = string
string = object.Text
Visual C++
object.SetText(string);
string = object.GetText( );
Delphi
object.Text:= string;
string:= object.Text;
The Text property syntax has these parts:
Part | Description |
object | A Branch object. |
string | A string 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 Propertyn 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.
The ProtoView TreeViewX Branch object supports the following methods:
Add | IsLocked | Remove |
Adds a new item to the Branch.
Syntax
Visual Basic
object.Add relation, relative, text
Visual C++
object.Add (relation, relative, text);
Delphi
object.Add (relation, relative, text);
The Add method syntax has these parts:
Part | Description |
object | A Branch object. |
relationship | A constant that specifies how the new item will be inserted into the list. |
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. |
Settings
The settings for relationship are:
Setting | Description |
pvtPositionInOrder | If the Sort Property is set to True, PositionInOrder
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 PositionInOrder 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. |
Remarks
To remove an item from a Branch, use the remove method.
Visual Basic Example
This example adds a number of items to a TreeViewX control. To try this example, create a form and place a TreeViewX 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 ChildNode As Branch Set root = PTreeView1.Branches Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5") Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5") Set ParentNode = root.Add(PositionInOrder, 0, "Parent Node 3") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 5") End Sub |
Visual C++ Example
This example adds a number of items to a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object in your project.
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(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"); } |
Removes all the child items from a Branch.
Syntax
Visual Basic
object.Clear
Visual C++
object.Clear ( );
Delphi
object.Clear;
The Clear method syntax has these parts:
Part | Description |
object | A Branch object. |
Remarks
If the object is the main Branch, then the TreeViewX control will be cleared of all items. Otherwise, only the children of the specified Branch will be cleared.
Visual Basic Example
This example clears a TreeViewX control. To try this example, create a form and place a TreeViewX 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 ChildNode As Branch Set root = PTreeView1.Branches root.Clear Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4") Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5") Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4") Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5") Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 3") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3") Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4") Set ChildNode = 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 |
Visual C++ Example
This example clears a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object 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.GetBranches()); 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.GetBranches()); root.Clear(); } |
Closes the Branch object according to command argument.
Syntax
Visual Basic
object.Close command
Visual C++
object.Close ( command );
Delphi
object.Close ( command );
The Close method syntax has these parts:
Part | Description |
object | A Branch object. |
command | A value or constant that specifies how the Close method will operate on the Branch object. |
Settings
The settings for command are:
Setting | Description |
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).
Visual Basic Example
This example closes the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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(pvtGetChild, 0) node.Close(pvtNode) End Sub |
Visual C++ Example
This example closes the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnClose method when pressed.
void MyDialog::OnClose() { CBranch root(m_treeview.GetBranches()); Cbranch node(root.Get(CBranch::pvtGetChild, 0)); node.Close(CBranch::pvtNode) } |
Returns a Branch object from a related Branch object.
Syntax
Visual Basic
object.Get relationship, relative
Visual C++
object.Get ( relationship, relative );
Delphi
object.Get ( relationship, relative );
The Get method syntax has these parts:
Part | Description |
object | A Branch object. |
relationship | A constant that specifies which new item will be obtained from the list. |
relative | A short integer 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. |
Settings
The settings for relationship are:
pvtGetNextSibling
Returns the next Branch object that is at the same hierarchical level in the TreeViewX 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 TreeViewX 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 TreeViewX 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 TreeViewX 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 TreeViewX control after this object. If no subsequent selected Branch object exists, the method returns an empty Branch objectK.
The relative argument is ignored if GetNextSelected is used.
pvtGetPrevSelected
Returns the previous Branch object that is selected on the TreeViewX 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 TreeViewX 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 TreeViewX 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.
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 TreeViewX 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.
Visual Basic Example
This example "walks" through the list of items in a TreeViewX 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 TreeViewX 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 |
Visual C++ Example
This example "walks" through the list of items in a TreeViewX 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 TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object 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(CBranch::pvtGetChild, 0); while ( node->IsValid() ) { node = &node->Get(CBranch::pvtGetNext, 0); } } |
The GetHandle method returns the item handle (HITEM) of the TreeViewX control item associated with the Branch.
Syntax
Visual Basic
handle = object.GetHandle
Visual C++
handle = object.GetHandle ();
Delphi
handle := object.GetHandle;
The GetHandle method syntax has these parts:
Part | Description |
object | A Branch object. |
handle | A handle which gives you direct access to the branch item. |
Remarks
The HITEM handle can be used with the hWnd Property to send messages directly to the TreeViewX control.
Returns a boolean value indicating whether or not the Branch object is locked.
Syntax
Visual Basic
boolean = object.IsLocked
Visual C++
boolean = object.IsLocked ();
Delphi
boolean:= object.IsLocked;
The IsLocked method syntax has these parts:
Part | Description |
object | A Branch object. |
boolean | A boolean expression which returns if a branch item is locked. |
Settings
The settings for boolean are:
Setting | 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.
Visual Basic Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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 |
Visual C++ Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0)); if ( node.IsLocked() ) node.Unlock(); else node.Lock(); } |
Returns boolean value indicating whether or not the Branch object is the main Branch object.
Syntax
Visual Basic
boolean = object.IsMainBranch
Visual C++
boolean = object.IsMainBranch ();
Delphi
boolean:= object.IsMainBranch;
The IsMainBranch method syntax has these parts:
Part | Description |
object | A Branch object. |
boolean | A boolean expression which returns if a branch item is the main branch. |
Settings
The settings for boolean are:
Setting | 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.
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
Visual Basic
boolean = object.IsOpen
Visual C++
boolean = object.IsOpen ();
Delphi
boolean:= object.IsOpen;
The IsOpen method syntax has these parts:
Part | Description |
object | A Branch object. |
boolean | A boolean expression which returns if a branch item is opened. |
Settings
The settings for boolean 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.
Returns boolean value indicating whether or not the Branch object is a valid Branch object.
Syntax
Visual Basic
boolean = object.IsValid
Visual C++
boolean = object.IsValid ();
Delphi
boolean:= object.IsValid;
The IsValid method syntax has these parts:
Part | Description |
object | A Branch object. |
boolean | A boolean expression which returns if a branch item is valid. |
Settings
The settings for boolean are:
Setting | 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.
Visual Basic Example
This example "walks" through the list of items in a TreeViewX 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 TreeViewX 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 |
Visual C++ Example
This example "walks" through the list of items in a TreeViewX 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 TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0); while ( node->IsValid() ) { node = &node->Get(CBranch::pvtGetNext, 0); } } |
Locks a Branch in a TreeViewX Control.
Syntax
Visual Basic
object.Lock
Visual C++
object.Lock ();
Delphi
object.Lock;
The Lock method syntax has these parts:
Part | Description |
object | A 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.
Visual Basic Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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 |
Visual C++ Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0)); if ( node.IsLocked() ) node.Unlock(); else node.Lock(); } |
Opens the Branch object according to command argument.
Syntax
Visual Basic
object.Open command
Visual C++
object.Open (command);
Delphi
object.Open (command);
The Open method syntax has these parts:
Part | Description |
object | A Branch object. |
command | A constant that specifies how the Open method will operate on the Branch object. |
Settings
The settings for command are:
Setting | Description |
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).
Visual Basic Example
This example opens the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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(Node) End Sub |
Visual C++ Example
This example opens the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0)); node.Open(CBranch::Node); } |
Removes and deletes a Branch from a TreeViewX Control.
Syntax
Visual Basic
object.Remove
Visual C++
object.Remove ();
Delphi
object.Remove;
The Remove method syntax has these parts:
Part | Description |
object | A 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.
Visual Basic Example
This example removes the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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 |
Visual C++ Example
This example removes the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object 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(CBranch::pvtGetChild, 0)); node.Remove(); } |
Selects or deselects the Branch object according to command argument.
Syntax
Visual Basic
object.Select command
Visual C++
object.Select (command);
Delphi
object.Select (command);
The Select method syntax has these parts:
Part | Description |
object | A Branch object. |
command | A constant that specifies how the Select method will operate on the Branch object. |
Settings
The settings for command are:
Setting | Description |
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.
Visual Basic Example
This example selects the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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 |
Visual C++ Example
This example selects the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0)); node.Select(CBranch::pvtNode)l } |
Unlocks a Branch in a TreeViewX Control.
Syntax
Visual Basic
object.Unlock
Visual C++
object.Unlock ();
Delphi
object.Unlock;
The Unlock method syntax has these parts:
Part | Description |
object | A 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.
Visual Basic Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX 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 |
Visual C++ Example
This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object 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(CBranch::pvtGetChild, 0)); if ( node.IsLocked() ) node.Unlock(); else node.Lock(); } |