Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Treeview


Hi

I have a basic treeview that allows me add/delete nodes. all nodes are stored in excel.

My problem: when i add/delete nodes via my form it does not store it on my excel sheet.

Can please someone care to help? I have attached my excel sheet.

My Code:


Code:
Option Explicit

Private m_lngKeyCount As Long

Private Sub CommandButton1_Click()
Unload Me
End Sub


Private Sub CommandButton2_Click()

Dim objNode As Node
Dim strKey As String

If TextBox1.Text <> "" Then
If Not TreeView1.SelectedItem Is Nothing Then
m_lngKeyCount = m_lngKeyCount + 1
strKey = "N" & CStr(m_lngKeyCount)
TreeView1.Nodes.Add TreeView1.SelectedItem, tvwChild, strKey, TextBox1.Text
End If
End If
End Sub

Private Sub CommandButton3_Click()

If Not TreeView1.SelectedItem Is Nothing Then
TreeView1.Nodes.Remove TreeView1.SelectedItem.Index
End If

End Sub

Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)

End Sub

Sub treeview()
Dim i As Integer
Dim nodX As Node
Dim strRel As String
Dim strRship As String
Dim strKey As String
Dim strText As String
Dim strTag As String

Worksheets("sheet1").Activate
Range("a3").Select

For i = 1 To 11
'cell A3
strRel = ActiveCell
'cell B3
strRship = ActiveCell.Offset(0, 1)
'cell C4
strKey = ActiveCell.Offset(0, 3)
'cell C3
strText = ActiveCell.Offset(0, 2)
'cell C5
strTag = ActiveCell.Offset(0, 4)

If strRship = "" Then
Set nodX = UserForm1.TreeView1.Nodes.Add(, , strKey, strText)
Else
Set nodX = UserForm1.TreeView1.Nodes.Add(strRel, tvwChild, strKey, strText)
End If
nodX.Tag = strTag
nodX.Expanded = True 'False

ActiveCell.Offset(1, 0).Select
Next
'UserForm1.Show

m_lngKeyCount = TreeView1.Nodes.Count

End Sub

Private Sub UserForm_Initialize()

treeview

TreeView1.Nodes(1).Selected = True

End Sub
Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Treeview - Capture Click Of Treeview Image
Hi,

I have a treeview where I am using the node image to mimic the functionality of a checkbox. Initially the node image (for topmost nodes only) is set to an image of an unchecked checkbox.

Is there any way to determine if the user clicks on the node image (and not the node text). I need to be able to alter the image from unchecked checkbox image to a checked checkbox image when the user clicks this image. However, I still want to allow the user to click the node text to expand/collapse the node as is the standard for this control.

Any help would be much appreciated.

TreeView - Want To Highlight Part Of TreeView
Hi, This must be a simple 1 line of code:

Have some VB code I didn't write, I am modifying it. Works OK but want to do one thing:-

The treeView has 1 branch called [NEW] A branch is inserted in and is highlighted (say called "hello"). I would like to set the highlight to the branch called "hello" not the original branch called [NEW].

The TreeView is called TVWizard.

I have used:-

TVWizard.setfocus

This sets the focus of the TreeView object. I somehow need to move the highlight to the "Hello" branch (node)

ONLY STARTED VB FEW WEEKS AGO, ANY HELP APPRECIATED

take it need something like TVWizard.Node("hello").focus = true ?????????

[VB6][TREEVIEW] How To Unchecked The Treeview Node
I would like to make a function for the user, when a user checked any of the parent node, the entire of child node and parent node will checked.
I tried to write on myself. The child node will checked if checked on parent node. However, i can't unchecked the child node if parent node unchecked.


Code:
Dim IndentifyCheck As Integer
Dim nodMP As Node
Dim nodP As Node
identifycheck = 0
If Node.Checked = True Then
If Not Node.Parent Is Nothing Then ' Parent exist.
Node.Parent.Checked = True
If Not Node.Parent.Parent Is Nothing Then
Node.Parent.Parent.Checked = True
End If

End If
If Not Node.Child Is Nothing Then
Set nodMP = Node.Child
Do Until nodMP Is Nothing
nodMP.Checked = True
If Not nodMP Is Nothing Then
Set nodP = nodMP.Child
Do Until nodP Is Nothing
nodP.Checked = True
Set nodP = nodP.Next
Loop

End If
Set nodMP = nodMP.Next
Loop

End If
Else
Do Until Node = Node.LastSibling
If Node.Checked Then
identifycheck = identifycheck + 1
End If
Set Node = Node.Next
Loop
If identifycheck < 1 Then
If Not Node.Parent Is Nothing Then
Node.Parent.Checked = False
If Not Node.Parent.Parent Is Nothing Then
Node.Parent.Parent.Checked = False
End If
End If
End If
If Not Node.Child Is Nothing Then
Set nodMP = Node.Child
Do Until nodMP Is Nothing
nodMP.Checked = False
If Not nodMP Is Nothing Then
Set nodP = nodMP.Child
Do Until nodP Is Nothing
nodP.Checked = False
Set nodP = nodP.Next
Loop

End If
Set nodMP = nodMP.Next
Loop

End If

End If

Treeview And Hyperlink Inside Treeview
Hi
I want to use the treeview for Statistic purpose.First,the user chooses one Keyword(it's an author),and when he clicks on the OK command,the keyword appears with a + on its left,when the user clicks on the +,it appears a collection of all the books the choosen Keywords has written(the collection of the books is obtained by an SQL query:
Select * from authors where author like '" & sauthor & "'" and each book written by the author will be added to the list with a + on its left

The user clicks on the book he wants to view its detail(he clicks on +),so he should see the date of publication(also this date is obtained from an SQL),and when he clicks on the + on the left of the keyword,the title of the book should appear as a hyperlink,when the user clicks on the hyperlink,it should display the cover of the book which is saved as a jpg file in the local disk

Can anyone guide me through the steps to accomplish this project?

Thanks in advance

Moving A Node From A Treeview To Another Treeview
I have created a program that displays 2 treeviews, let's call them treeview1 and treeview1. The content of the nodes are taken from 2 different xml files. I would just like to know how i can click, drag and drop a node from treeview1 to treeview2. thanks!

Treeview To Treeview Form
how do you transfer from one treeview form to another treeview form ??

How To Copy Treeview To Treeview!?
Hi there,
I was wondering how I would go abouts in copying a treeview to another treeview? I've seen a few code on some websites, but they just do not work. I am not using a standard treeview, I am using the vbaccelerator treeview control.

Treeview Control Without Imagelist/using System Imagelist In Treeview
I am reposting this here because I didn't get a response in the VB 5/6 forum. The getfileinfo api function returns the system imagelist (?) and index to the files icon. Is there a way of using this list and index in the treeview control ? Any help would be appreciated

I am writing an applicatiion that simulates explorer using the treeview control. I've been able to extract the icon from a file using the WinApi but have not found an example where I can use a picture without an imagelist. Its impractical to add all the files on a system to an image list.

Is there a way to do this ?

Thanks,

Michael Zwijacz
mzwijacz@tahoesnow.com

TreeView
Hi all,

I would like to map a text line which is looks like :
A,B,C,D,E under the treeview control in order to get the following output:

A
:-- B
:----- C
:-------D
:-------- E

Can anyone help to do that and show me in a simple way how the treeview control work.

Thanks

Treeview
Is there any way you can set the back colour and fore colour of a treeview control?

TreeView Bug
Hi,

I have a big problem with a TreeView, due a Bug (I think)

I'm using a TreeView with checkboxes to show all permissions of the program, Example: Window1 -> Add, Edit, Delete , Query, and there for all windows, well my Fill TreeView routine is working well, all its fine, while the TreeView doesn't have assigned a ListImage Control, when I assing a ListImage control to the TVW the checkboxes always are unchecked even my routine checked them.

The way of calling the Fill TreeView routine its this one:


From Window where Users of the program are enumerated:

Code:
Private Sub lvwUsers_DblClick
......

Load frmPermissions
frmPermission.LoadUser (<Selected User Index>)
frmPermission.Show
......
End Sub

Code in the LoadUser into frmPermissions

Code:
Public Sub LoadUser
FillPermissionsTree (Works fine)
....
.....

'Here Starts my routine where only the permissions that have assigned the user are checked

For I = 1 to tvwPermission.Nodes.Count
If <Condition> Then
tvwPermission.Nodes(I).Checked = True
Exit For
End If
Next I

End Sub

Thats my way of doing this, I think nothing is bad in this routine.

Well, I hope make sense this post, Thanks

Treeview
alright, i know this question as been asked before, but there was no answer, so i try again.
i have a window with two frames: on the left side a frame with a treeview in it, on the right side a frame which will show the appropiate info, belonging to a 'clicked' item in the treeview.

the problem was that loading the data in the treeview (from a database) takes a lot of time. so: i managed to decrease the loading time considerebly, by only loading the first 2 levels of the tree, the rest is being loaded on a nodeclick event, and for algortithmic purposes, when u click on say, level 2, it loads untill level 4 (so 2 in one). (has to do with my database, it's kinda complicated)

but: and here's the problem: when a user doubleclicks on an item from the tree, it should be (vb does that itself, normal behavore) like a nodeclick event, and expand a level....

it doesn't do that: it skips some data to be loaded, not much, but some. does anybody have a clue how to fix this, -or- disable the doubleclick thing?

thanx!

Treeview
I have a treeview.

How can I, when I click on a node, debug.print all the underlaying nodes?

Thanks

Treeview
I have a treeview control that displays all the information stored in my program. What I need to do rebuild the tree structure without collapsing the entire structure. Is there a way of storing which trees are open and which item is currently selected, (then clear and rebuild the tree) and finally restoring this state at a later time?

Also, if anyone knows how to simply expand a certain tree this would be useful and might help me figure out the rest.

Thank-you.

TreeView Help
Hi,

I'm a newbie developing an app in VB 6- I've got a treeview control that I am struggling with....

The scenario is this. When the user clicks on one of the node objects, I want text detail to appear in a textbox to the right of the control. I've gotten this to work, but when I click on any area in the control that is NOT on a node, I get the following error: "Object Variable or With block variable not set".

My code for the Mousedown action looks like this(where the error is coming from) -

Any help would be appreciated....

Thanks

Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.TreeView1.SelectedItem = Me.TreeView1.HitTest(X, Y)
Set rs = db.OpenRecordset("Coach")
While Not rs.EOF
' If text matches a database entry, then pop up details in textbox
If TreeView1.SelectedItem.Text = rs!Coach_F & " " & rs!Coach_L Then

txtGeneo.Text = rs!Coach_F
rs.MoveLast
rs.MoveNext
Else
rs.MoveNext
End If
Wend
End Sub

TreeView Big Help
Ok can someone help me i really cant figure out this i need two Parents and ima use a Ton of Childs but idk how to give a Child a command such as when a child is selected it does something im better in seeing code can someone help me please

I Need Help With Treeview
Hello!

Is there any posibillity to export contents of treeview component to a file or maybe a variable (like variant type). I mean exporting the nodes with all the hierarchy.

Thanks in advance for all your help.

How To? (treeview)
how can i make a treeview look more like this;

|node1
|childnode2
|childnode3

instead of

|node1
|---childnode2
|---childnode3

i am trying to get the first example and still be able to expand it?

how on earth ca i do this???

Treeview
can anyone teach me on how to use a treeview?
im kind of new here

Treeview Help
Can someone help me find a tutorial on using the treeview? I was not able to find one in this forum and was a little lost in the Microsoft description. Thanks in advance for any information you can give.
Stuart

TreeView
Hello,

I've built an application where I can show the information from a database.
I will use a TreeView where I can show the orders of my table and the suborders of my table.
I tried to make this and it works. But I have a small question about the properties for the treeview. In a textbox you have the propertie "Mulitline" to show more line information. Now in my suborders I need to show also more than 1 line. Is there a possibilitie to do this, because now I only see a part of my information in the treeview?
Is it also possible to change the backcolor and forecolor?

Br, Peter.

Help On TreeView
Hi Guys

Anyone who can quickly help me specifically with the creation of TreeView,Ok what I want to create this TreeView from the data I have in my Database (MS Access),like the Parent folder and the Child folder,so and so on.

I will appriciate if someone can help me as soon as possible.Thanx friends.

Regards

Tman

Treeview
Hi,
Can anyone tell me if there is a maximum value for a tree view
i.e. the number of records allowed to be added to the control.

Thanks

Ian.

Treeview
My treeview is as follows


Group AhahaGroup BLalaWOWASDFI need to return all the items under the "group b" heading... but I won't always know how many are there so I guess I'll need a loop. Not sure how to pull off just the children from that group though. Any ideas?

Treeview!
1. How can I check if an item with a certain Key exists in a treeview control?
I tried:

Code:
If tvwDirList.Nodes.Item(sKey) Is Nothing Then
'
End If
but got an error saying 'Element not found'. I realize I can use it with error trapping but I'd rather not...

2. I'm trying to create some sort of explorer and I want it to look like the one in the attachment.
My problem is with the items marked with a red dot. How can I scan for them?
Obviously Dir$ wouldn't help...

TreeView Help
I understand the coding to add stuff the the tree vied, but where do I put the code at?

TreeView
I would like to know how I can have it so when an item is selected in my treeview control a label says something. How can I accomplish this?

TreeView ???
Please Help I am a newbee in Treeview Control

If i have a Treeview on form with a structure as shown

A---
|-->1---
||---a---
|||---i
|||---ii
||
||---b
|
|
|-->2---
||..
...
..
..
..
|-->3

how can i write a sub which on accepting a string which will be Node.text and a Boolean variable, will check the node specified.....

Thx in advance.

Treeview
i know i have asked this before, but can someone help me find a real simple treeview? I looked at an example on msdn but i couldnt seem to get it to work.

Treeview
Im looking to make a treeview based file manager system that will allow files to be viewed from another machine. I have a server client system set up already, and have started working on the treeview interface before i try and update the information remotely. I searched out a tutorial on how to do it, and came across this site...

http://abstractvb.com/code.asp?F=49&P=2&A=716

I seem to be having problems getting the code to work, i believe its because of this line...

Set foNode = TreeView1.Nodes.Add(parent, tvwChild, ,_
folder.Name, "ClosedFolder")

this appears in a strange format as it is seperated and put on two lines, plus underscore is not used in vb6...

anyone tried this and have been successful in getting it to work? im also looking for links for info on how to remotely update the information... any help appreciated, cheers.

Treeview
Hi.

Somehow I'm having problems with the treeview.
If I use the code below, I get the following error (on the 2nd line):
'invalid object'


Code:
Set mNode = tvwKlanten.Nodes.Add("Klanten", tvwChild, rsSpecificatie!klantnaam, rsSpecificatie!klantnaam)
Set mNode = tvwKlanten.Nodes.Add(rsSpecificatie!klantnaam, tvwChild, "", rsSpecificatie![iso-nummer])

If I change the 2nd line like this:

Code:
Set mNode = tvwKlanten.Nodes.Add("Klanten", tvwChild, rsSpecificatie!klantnaam, rsSpecificatie!klantnaam)
Set mNode = tvwKlanten.Nodes.Add("--", "", rsSpecificatie![iso-nummer])
It works. The value of the rsSpecificatie!klantnaam is "--". Somehow it I link to the the recordset it just doesn't work.

Any suggestions?

B.R.

Patrick.

Treeview
I have a Treeview, with Roots and Nodes

I want all of them to be expanded once it is opened the first time.

Thanks

Treeview?
I'm having trouble trying to recreate (see picture). If anyone can help it would be greatly appreciated. I've looked all over google trying to find code to show me how to do this, but have come up with nothing but headaches...

TreeView
Is there an easy way to copy the contents from one TreeView to another?

Treeview Help !
just a few questions to be honest. But the main one is the treeview issue, this is related to API, i probably should have put this in API Category, anyway...

I have a business application that i wish to add additional nodes to its treeview using API.

This business app is not written in VB nor do i have the source code, i know for sure its just using standard treeview because i can use standard treeview api calls on it (for example : TVM_GETITEM )

Whats the api to add new nodes to a treeview? i need some examples in vb if possible (posting code will be fine)

The other question i had was using appendmenu how do i add new menu items to existing menus within an app (the business application again)? i only know about CreateNewPopup...

One of the menus i wish to add new items to is actually a popup when you right click on a listview the menu appears.

Thats all for now...

thanks in advance,

About The Treeview
Hi all,

I am currently using the treeview control for a program.

The problem is that when a node if the tree contains a text that is too long in regard of the tree's width, a yellow box appears to display the whole text when I put my mouse on this specifis line.

I find this extremely annoying and I would like to avoid that.

Is there a way to do that???


Thanks for advance.


Stéphane

TreeView Key
I have a TreeView and I'm running into problems with items on the tree having the same key. I need to fix this and I want to do it by making a new node have the parent node's text and it's text concatenated together to create the new node's key. Can anyone help? Here is my code:
This is only one portion, more will be supplied upon demand

Code:
Private Sub Form_Load()
' Declare variables

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaSet As OraDynaSet

Dim OraFields As OraFields

' Create the OraSession Object. The argument to CreateObject is the
' name by which theOraSession object is known to the OLE system.

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

' Create the OraDatabase Object by opening a
' connection to Oracle.

Set OraDatabase = OraSession.OpenDatabase("PKDEMO", "pkdemo/pkdemo", 0&)

' Create the OraDynaset Object.

Set OraDynaSet = OraDatabase.CreateDynaset("select PS_IMKEY,PS_CPKEY from PS where PS_IMKEY = '2101357'", 0&)
Set OraFields = OraDynaSet.Fields

OraDynaSet.MoveFirst
TreeView1.Nodes.Clear
With TreeView1.Nodes
.Add , , "TOGGLE SWITCH", "TOGGLE SWITCH"
Do While Not OraDynaSet.EOF
.Add .Item("TOGGLE SWITCH"), tvwChild, OraFields("PS_CPKEY").Value, OraFields("PS_CPKEY").Value
PSCPKEY = OraFields("PS_CPKEY").Value
Call Check_Node(PSCPKEY)
OraDynaSet.MoveNext
Loop

End With
Call Select_Expand
Call Assign_Icons
ItemForm.Show vbModeless, Me
End Sub

Thanks in advance, Jeremy

Treeview
How must i show my entire treeview when the program starts

example:

now

Code:
brugge

i want this:

Code:
brugge
--jordy
--lid1
--lid2
--bert
--lid3
--pol
...

Plz Help My With My Treeview
When i click on my last node i get lots of information.

I want to change some of the things in my node and then do an update. The things in my node are update but not my node himself.

How must i update(refresh) my treeview????

Treeview
How must i search in a treeview??

I want a search button that looked for a node in the treeview

Treeview
i have check marks next to my list in the treeview

say i want to know if they've checked a parent or root node. i can tell if theyve done it with

node.parent

if node.parent = nothing then it's root

but if node.parent = nothing then...
doesn't work

nore does ismissing()

what could i use?

Treeview ?
I have treeview with 3 parent nodes each of the parent nodes have children with their own children etc. I came up with a routine that will allow a user to show only the child node of a parent that they select. i.e. all other child nodes are removed from that parent node. I would like to be able to do this for the parent nodes also. That is if a user highlights parent node 1 then parent nodes 2 and 3 are removed. I thought that filtering the parent nodes would be easy but I cannot seem to figure out how to do this. Any ideas?

TreeView
How can I add a parent to an already exsiting tree Have
online
ted

but when the user logs on I want them to see

online
offline
ted

and also besides slapping on the other parent node on the tree how can I indent the username
online
George

offline
ted

Thanks,
JOhn

Treeview
I have one nice problem (read biggggg)!
On my form I have treeview control with some data from database. But treeview is to small to show all data on screen (screen is to small). With scroll bar I could see all data. So, is it possible to print all treeview :
- on one page (zooming, decreased font…..)
- on more then one page (no zooming )
- change orientation of paper if data in treeview is wide then paper…

TreeView
Someone already sort of answered my question about this but I'm not sure i got down path. Here is my question...
How can i create a tree view from table names and field names in my Access database. I know you use TableDefs but how do i incorposate this to create a tree view. Thanks for any help

TreeView
Hi, instead of the standard text on the treeview, how can I place an image or icon on the left to the text?

TreeView
Is there a way to set the treeveiw to left align with the root nodes, rather than left aligning with the expanded child nodes ?

Thanks in advance

Treeview Help
how do I check if there is a node selected in a treeview.

I want to do something like this to check if there is actually something selected or not, but my code doesn't work.

If treeview1.selecteditem.text = "" then

Treeview From DB
Hello again!

I'm trying to populate my Treeview from DB. It works good except Child nodes. The problem is, that I want to populate it like this:

Table name: URL
Fields: Kategorija, Podkategorija

Private Sub vpisi_treeview()

Set rs = db.OpenRecordset("SELECT DISTINCT Kategorija FROM URL", dbOpenSnapshot)
If Not rs.EOF And Not rs.BOF Then
With rs
.MoveFirst
Do Until .EOF
Set vozel = TV1.Nodes.Add(, , , !Kategorija)
vozel.Image = 1
Set rs1 = db.OpenRecordset("SELECT DISTINCT Podkategorija FROM URL WHERE Kategorija = '" & !Kategorija & "'", dbOpenDynaset)
With rs1
.MoveFirst
Do Until .EOF
If Not IsNull(!Podkategorija) Then
Set vozel = TV1.Nodes.Add(1, tvwChild, , !Podkategorija)
End If
.MoveNext
Loop
End With
rs1.Close
.MoveNext
Loop
End With
End If

End Sub

Where "Kategorija" = Databases, Text, Forms & controls etc, and "Podkategorija" = DAO, ADO, Compare string, Arrays, etc (Like: Kategorija = Databases, Podkategorija = DAO or ADO...)

What is going on here is that Child nodes don't appear under the right (parent) node but under the first node in the Treeview (All of them).

How can I do this the right way?

Regards!
Ales Zigon

Copyright © 2005-08 www.BigResource.com, All rights reserved