473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Treatise on Tree Control 6.0?

I'm getting nodes into the thing, but when the dust settles, only the root-level
nodes are visible.

I know they're there because .Nodes.Count gives the right number.\

But I don't really understand the significance of the Nodes.Add syntax - I'm
just slavishly plugging in values.
Viz:

---------------------------
Public Sub ClassMembersLoad(ByVal theClassID As Long, ByVal theMaxLevels As
Long)
1000 debugStackPush Me.Name & ": ClassMembersLoad"
1001 On Error GoTo ClassMembersLoad_err

' PURPOSE: Allow the "Classes" subform to load the "ClassMember"
' tree with members of currently selected class
' ACCEPTS: - ClassID of class's members TB loaded.
' - Max levels TB expected for the class in question

1002 Dim thisDB As DAO.Database
Dim myRS As DAO.Recordset
Dim myQuery As DAO.QueryDef
Dim curNode As Node
Dim curChild As String
Dim curParent As String

Dim i As Integer

1009 Me.treClassMembers.Nodes.Clear

1010 Set thisDB = CurDB()

1020 For i = 1 To theMaxLevels
1030 Set myQuery = thisDB.QueryDefs("qryAdminClassMembersLoad")
1031 With myQuery
1032 .Parameters("theClassID") = theClassID
1033 .Parameters("theLevel") = i
On Error Resume Next
myRS.Close
On Error GoTo ClassMembersLoad_err
1035 Set myRS = .OpenRecordset(dbOpenSnapshot, dbForwardOnly)
1039 End With

1040 With myRS
1041 If Not ((.BOF = True) And (.EOF = True)) Then
1042 Do Until .EOF = True
1043 If Val(!ParentClassMemberID & "") = 0 Then
1044 curChild = !ChildName & "-" & !ChildDescription
1045 Set curNode = Me.treClassMembers.Nodes.Add(, , curChild,
curChild)
'1045 Set curNode = Me.treClassMembers.Nodes.Add(, ,
CStr(!ChildClassMemberID), curChild)
1046 Else
1049 curChild = !ChildName & "-" & !ChildDescription
1050 curParent = !ParentName & "-" & !ParentDescription
1051 Set curNode = Me.treClassMembers.Nodes.Add(curParent,
tvwChild, curChild, curChild)
'1051 Set curNode = Me.treClassMembers.Nodes.Add(curParent,
tvwChild, !ChildClassMemberID, curChild)
' Set curNode = trTable.Nodes.Add(CStr(recLevel2("level1")),
tvwChild, CStr(recLevel2("NodeName")) & "(" & CStr(recLevel2("NodeName")) & ")",
recLevel2("level2"))
1052 End If
1053 .MoveNext
1054 Loop
1055 End If
1059 End With
1999 Next i

'With Me.treClassMembers.Nodes
' For i = 1 To .Count
' Debug.Print .Item(i)
' Next i
'End With
ClassMembersLoad_xit:
debugStackPop
On Error Resume Next
Set myQuery = Nothing
myRS.Close
Set myRS = Nothing
Set thisDB = Nothing
Exit Sub

ClassMembersLoad_err:
bugAlert True, ""
Resume ClassMembersLoad_xit
End Sub
---------------------------

Some time ago Larry Linton pointed me to
http://www.mvps.org/ccrp/controls/ccrpftv6.htm
which works great.

Only problem is that with my current project there is zero chance of registering
an new OCX on a user's machine (corporate security policy).

So I'm back to the plain-vanilla-out-of-the-box control.

Anybody know where to find a decent writeup on the ins and outs of using it.

--
PeteCresswell
Nov 12 '05 #1
4 1863
The attached, from the VB help file, may be of use to you:

Syntax

object.Add(relative, relationship, key, text, image, selectedimage)

The Add method syntax has these parts:

Part Description
Object Required. An object expression that evaluates to an object in the
Applies To list.
Relative Optional. The index number or key of a pre-existing Node object.
The relationship between the new node and this pre-existing node is found in
the next argument, relationship.
Relationship Optional. Specifies the relative placement of the Node object,
as described in Settings.
Key Optional. A unique string that can be used to retrieve the Node with the
Item method.
Text Optiona. The string that appears in the Node.
Image Optional. The index of an image in an associated ImageList control.
Selectedimage Optional. The index of an image in an associated ImageList
control that is shown when the Node is selected.
Settings

The settings for relationship are:

Constant Value Description
TvwFirst 0 First. The Node is placed before all other nodes at the same
level of the node named in relative.
TvwLast 1 Last. The Node is placed after all other nodes at the same level
of the node named in relative. Any Node added subsequently may be placed
after one added as Last.
TvwNext 2 (Default) Next. The Node is placed after the node named in
relative.
TvwPrevious 3 Previous. The Node is placed before the node named in
relative.
TvwChild 4 Child. The Node becomes a child node of the node named in
relative.
Note If no Node object is named in relative, the new node is placed in the
last position of the top node hierarchy.

Remarks

The Nodes collection is a 1-based collection.

As a Node object is added it is assigned an index number, which is stored in
the Node object's Index property. This value of the newest member is the
value of the Node collection's Count property.

Because the Add method returns a reference to the newly created Node object,
it is most convenient to set properties of the new Node using this
reference. The following example adds several Node objects with identical
properties:

Private Sub CreateNodes()
' Set CheckBoxes property to True to see checked nodes:
TreeView1.CheckBoxes = True
Dim nodX As Node ' Declare the object variable.
Dim i as Integer ' Declare a counter variable.
For i = 1 to 4
Set nodX = TreeView1.Nodes.Add(,,,"Node " & Cstr(i))
' Use the reference to set other properties, such as Bold.
NodX.Bold = True
' Set image property to image 3 in an associated ImageList.
nodX.Checked = True
Next i
End Sub

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)

"(Pete Cresswell)" <x@y.z> wrote in message
news:j2********************************@4ax.com...
I'm getting nodes into the thing, but when the dust settles, only the root-level nodes are visible.

I know they're there because .Nodes.Count gives the right number.\

But I don't really understand the significance of the Nodes.Add syntax - I'm just slavishly plugging in values.
Viz:

---------------------------
Public Sub ClassMembersLoad(ByVal theClassID As Long, ByVal theMaxLevels As Long)
1000 debugStackPush Me.Name & ": ClassMembersLoad"
1001 On Error GoTo ClassMembersLoad_err

' PURPOSE: Allow the "Classes" subform to load the "ClassMember"
' tree with members of currently selected class
' ACCEPTS: - ClassID of class's members TB loaded.
' - Max levels TB expected for the class in question

1002 Dim thisDB As DAO.Database
Dim myRS As DAO.Recordset
Dim myQuery As DAO.QueryDef
Dim curNode As Node
Dim curChild As String
Dim curParent As String

Dim i As Integer

1009 Me.treClassMembers.Nodes.Clear

1010 Set thisDB = CurDB()

1020 For i = 1 To theMaxLevels
1030 Set myQuery = thisDB.QueryDefs("qryAdminClassMembersLoad")
1031 With myQuery
1032 .Parameters("theClassID") = theClassID
1033 .Parameters("theLevel") = i
On Error Resume Next
myRS.Close
On Error GoTo ClassMembersLoad_err
1035 Set myRS = .OpenRecordset(dbOpenSnapshot, dbForwardOnly)
1039 End With

1040 With myRS
1041 If Not ((.BOF = True) And (.EOF = True)) Then
1042 Do Until .EOF = True
1043 If Val(!ParentClassMemberID & "") = 0 Then
1044 curChild = !ChildName & "-" & !ChildDescription
1045 Set curNode = Me.treClassMembers.Nodes.Add(, , curChild, curChild)
'1045 Set curNode = Me.treClassMembers.Nodes.Add(, ,
CStr(!ChildClassMemberID), curChild)
1046 Else
1049 curChild = !ChildName & "-" & !ChildDescription
1050 curParent = !ParentName & "-" & !ParentDescription
1051 Set curNode = Me.treClassMembers.Nodes.Add(curParent,
tvwChild, curChild, curChild)
'1051 Set curNode = Me.treClassMembers.Nodes.Add(curParent,
tvwChild, !ChildClassMemberID, curChild)
' Set curNode = trTable.Nodes.Add(CStr(recLevel2("level1")), tvwChild, CStr(recLevel2("NodeName")) & "(" & CStr(recLevel2("NodeName")) & ")", recLevel2("level2"))
1052 End If
1053 .MoveNext
1054 Loop
1055 End If
1059 End With
1999 Next i

'With Me.treClassMembers.Nodes
' For i = 1 To .Count
' Debug.Print .Item(i)
' Next i
'End With
ClassMembersLoad_xit:
debugStackPop
On Error Resume Next
Set myQuery = Nothing
myRS.Close
Set myRS = Nothing
Set thisDB = Nothing
Exit Sub

ClassMembersLoad_err:
bugAlert True, ""
Resume ClassMembersLoad_xit
End Sub
---------------------------

Some time ago Larry Linton pointed me to
http://www.mvps.org/ccrp/controls/ccrpftv6.htm
which works great.

Only problem is that with my current project there is zero chance of registering an new OCX on a user's machine (corporate security policy).

So I'm back to the plain-vanilla-out-of-the-box control.

Anybody know where to find a decent writeup on the ins and outs of using it.
--
PeteCresswell

Nov 12 '05 #2
rkc

"(Pete Cresswell)" <x@y.z> wrote in message
news:j2********************************@4ax.com...
I'm getting nodes into the thing, but when the dust settles, only the root-level nodes are visible.

I know they're there because .Nodes.Count gives the right number.\

But I don't really understand the significance of the Nodes.Add syntax - I'm just slavishly plugging in values.


You appear to be trying to create a parent node and add a child node using
one
statement. It doesn't work that way.

The root node has to be created first using
..Add (, , Key, VisibleText)

Then a child node can be added to it using the root nodes Key value.
..Add(Key, tvwChild, childKey, VisibleText)

If you want to add a child node to the child node you would use the
childKey as the root node Key value.


Nov 12 '05 #3
RE/
I'm getting nodes into the thing, but when the dust settles, only the root-level
nodes are visible.


I think I've got it doped out.

All available events are not listed in the props dialog - but if you to to a
code window, events like NodeClick are visible.

That, plus discovering that .Item(x) is really a Node....I'm livin' large...
--
PeteCresswell
Nov 12 '05 #4
RE/
The attached, from the VB help file, may be of use to you:


For sure! Thanks...on my installation of Office 2000 the help files sort of come
and go..and lately they've gone...
--
PeteCresswell
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
3
by: Toxick | last post by:
Hello experts, I'm a total C# noob with a total C# noob question. I've been Serializing in C++ (MFC) and writing data to std::fstreams for quite some time, so maybe I'm not understanding...
4
by: David W. Simmonds | last post by:
Outside of building a custom ActiveX control that would need to run on the user's machine and have security attributes set to allow such, does anyone have any code that will allow a combobox to...
10
by: dwok | last post by:
Does anyone know of a good article that discusses creating a "Tree View" control in ASP.NET? Or perhaps a Tree View Control that comes with source code? I have come across a lot of tree controls...
7
by: Andrew Robinson | last post by:
I have a treeview control that I use as a menu & navigation control within a master page. The nodes for this control are loaded from a database which contains the text and url of each like and the...
3
by: _DS | last post by:
Problem with mapping a directory tree to a tree control: It takes a while to recurse subdirs and map them to nodes. This is solved in some books I've seen (MacDonald, Albahari) by reading the...
2
by: Kiran | last post by:
Hello all, I am using a tree to display stuff, and it is constantly updated, but what I have noticed is in the lowest level, there is clearly noticable cutoff of the text I place there. The cutoff...
1
by: perspolis | last post by:
Hi all I'm looking for a Combobox that displays tree. Does anyone has a source code for that??? thanks in advance
2
by: Tom | last post by:
My older system: Win2k, VS2005(Academic), .Net 2.0 SP1. Windows.Forms Application: Two splitter panels, a TreeView (named: "tree") in one panel populated with directory name nodes. Logic for...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.