ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help with Treeview control ?? (https://www.excelbanter.com/excel-programming/318667-need-help-treeview-control.html)

Dan Thompson

Need help with Treeview control ??
 
Hi there I am extreamly frustrated because I have recently discoverd the
treeview control but am unable to use it. I have found nothing in the Excel
VBA help files of use and every search I have done for a example code has
been either far to complex or had errors in in it before I edited anything.
Could someone please help me with a small very very very basic example code
for populating and using the Treeview control on a vba form.

Thanks, Dan


Tom Ogilvy

Need help with Treeview control ??
 
http://support.microsoft.com/default...b;en-us;244954
How To Populate a Treeview Control with an XML File

The treeview control is not distributed with microsoft office, so you
wouldn't expect to find anything about it in the help files for excel.

--
Regards,
Tom Ogilvy

"Dan Thompson" wrote in message
...
Hi there I am extreamly frustrated because I have recently discoverd the
treeview control but am unable to use it. I have found nothing in the

Excel
VBA help files of use and every search I have done for a example code has
been either far to complex or had errors in in it before I edited

anything.
Could someone please help me with a small very very very basic example

code
for populating and using the Treeview control on a vba form.

Thanks, Dan




Dan Thompson

Need help with Treeview control ??
 
Well that may be true however I have added The treeview control to my forms
toolbox and have such added the control to my form I am able to refference it
withing Excel VBA code too for example

With Me
Treview1.Nodes.Add(blah blah blah)
end with
but when I add the nodes and run the control on my form nothing happens
I know that this control can be used in a Excel VBA form.
Im just not sure how to get it going has anyone used this control on a Excel
VBA form before that can help me with a small working sample ?

Thanks Dan Thompson



"Tom Ogilvy" wrote:

http://support.microsoft.com/default...b;en-us;244954
How To Populate a Treeview Control with an XML File

The treeview control is not distributed with microsoft office, so you
wouldn't expect to find anything about it in the help files for excel.

--
Regards,
Tom Ogilvy

"Dan Thompson" wrote in message
...
Hi there I am extreamly frustrated because I have recently discoverd the
treeview control but am unable to use it. I have found nothing in the

Excel
VBA help files of use and every search I have done for a example code has
been either far to complex or had errors in in it before I edited

anything.
Could someone please help me with a small very very very basic example

code
for populating and using the Treeview control on a vba form.

Thanks, Dan





Harald Staff

Need help with Treeview control ??
 
Hi Dan

Short explanation of the Blah blah part:

Nodes.Add(Key of parent node, relation to parent node, unique node key, node
text, optional icon to display)

Private Sub UserForm_Initialize()
Dim L1 As Long, L2 As Long
With Me.TreeView1
Dim NodX As Node
Set NodX = .Nodes.Add(, , "Root", "My main node")
Set NodX = Nothing
For L1 = 1 To 6
Set NodX = .Nodes.Add("Root", tvwChild, _
"Sub" & L1, "Child " & L1)
NodX.EnsureVisible
Set NodX = Nothing
For L2 = 1 To 12
Set NodX = .Nodes.Add("Sub" & L1, tvwChild, _
"Sub" & L1 & "sub" & L2, "Grandhild " & L1)
Set NodX = Nothing
Next
Next
End With
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Key = "Root" Then
MsgBox "I'm root."
Else
MsgBox "You just clicked " & Node.Key & ", proud child of the great " &
_
Node.Parent.Key
End If
End Sub

HTH. Best wishes Harald

"Dan Thompson" skrev i melding
...
Well that may be true however I have added The treeview control to my

forms
toolbox and have such added the control to my form I am able to refference

it
withing Excel VBA code too for example

With Me
Treview1.Nodes.Add(blah blah blah)
end with
but when I add the nodes and run the control on my form nothing happens
I know that this control can be used in a Excel VBA form.
Im just not sure how to get it going has anyone used this control on a

Excel
VBA form before that can help me with a small working sample ?

Thanks Dan Thompson



"Tom Ogilvy" wrote:

http://support.microsoft.com/default...b;en-us;244954
How To Populate a Treeview Control with an XML File

The treeview control is not distributed with microsoft office, so you
wouldn't expect to find anything about it in the help files for excel.

--
Regards,
Tom Ogilvy

"Dan Thompson" wrote in message
...
Hi there I am extreamly frustrated because I have recently discoverd

the
treeview control but am unable to use it. I have found nothing in the

Excel
VBA help files of use and every search I have done for a example code

has
been either far to complex or had errors in in it before I edited

anything.
Could someone please help me with a small very very very basic example

code
for populating and using the Treeview control on a vba form.

Thanks, Dan







Dan Thompson

Need help with Treeview control ??
 
Thanks Harald
That worked GREAT!
You were a big help, realy apreciate your input.

Dan


"Harald Staff" wrote:

Hi Dan

Short explanation of the Blah blah part:

Nodes.Add(Key of parent node, relation to parent node, unique node key, node
text, optional icon to display)

Private Sub UserForm_Initialize()
Dim L1 As Long, L2 As Long
With Me.TreeView1
Dim NodX As Node
Set NodX = .Nodes.Add(, , "Root", "My main node")
Set NodX = Nothing
For L1 = 1 To 6
Set NodX = .Nodes.Add("Root", tvwChild, _
"Sub" & L1, "Child " & L1)
NodX.EnsureVisible
Set NodX = Nothing
For L2 = 1 To 12
Set NodX = .Nodes.Add("Sub" & L1, tvwChild, _
"Sub" & L1 & "sub" & L2, "Grandhild " & L1)
Set NodX = Nothing
Next
Next
End With
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Key = "Root" Then
MsgBox "I'm root."
Else
MsgBox "You just clicked " & Node.Key & ", proud child of the great " &
_
Node.Parent.Key
End If
End Sub

HTH. Best wishes Harald

"Dan Thompson" skrev i melding
...
Well that may be true however I have added The treeview control to my

forms
toolbox and have such added the control to my form I am able to refference

it
withing Excel VBA code too for example

With Me
Treview1.Nodes.Add(blah blah blah)
end with
but when I add the nodes and run the control on my form nothing happens
I know that this control can be used in a Excel VBA form.
Im just not sure how to get it going has anyone used this control on a

Excel
VBA form before that can help me with a small working sample ?

Thanks Dan Thompson



"Tom Ogilvy" wrote:

http://support.microsoft.com/default...b;en-us;244954
How To Populate a Treeview Control with an XML File

The treeview control is not distributed with microsoft office, so you
wouldn't expect to find anything about it in the help files for excel.

--
Regards,
Tom Ogilvy

"Dan Thompson" wrote in message
...
Hi there I am extreamly frustrated because I have recently discoverd

the
treeview control but am unable to use it. I have found nothing in the
Excel
VBA help files of use and every search I have done for a example code

has
been either far to complex or had errors in in it before I edited
anything.
Could someone please help me with a small very very very basic example
code
for populating and using the Treeview control on a vba form.

Thanks, Dan








Harald Staff

Need help with Treeview control ??
 
"Dan Thompson" skrev i melding
...
Thanks Harald
That worked GREAT!
You were a big help, realy apreciate your input.


Glad to hear that Dan. Thanks for the feedback.
Best wishes Harald




All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com