| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual Basic 6.0 Programming Ask questions about VB 6.0 (or earlier versions) or help others by answering their question. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Expanding Tree View
I have a tree view in my application. I already have a sub which collapses the entire tree. I need a sub which expand all the codes in the tree view. I am fairly new to vb.. Help greatly appreciate.. please ask any questions u have.
here is the code to the Collapse sub Private Sub RepExpTV_Click() For k = 1 To TreeView1.Nodes.Count TreeView1.Nodes(k).Expanded = False Next k End Sub |
|
#2
|
|||
|
|||
|
Question:
Are you collapsing nodes on the server side or on the client side? The reason that I ask is because there is a difference with how it would be handled. Will |
|
#3
|
|||
|
|||
|
The database file is on my computer. Its more like a TreeView (TV) I am playing about it. I have a Report Menu under which is the following choice. -> Collapse all entries in TreeView. I need to have a choice which Expands the entire treeview.
Thank you |
|
#4
|
|||
|
|||
|
However when the application is used..ppl will go on the network to find the database file which is used to make the tree nodes
|
|
#5
|
|||
|
|||
|
Edited:
Sorry I did not understand the question. Last edited by womalley; July 31st, 2003 at 07:36 AM. |
|
#6
|
|||
|
|||
|
When the Menu option is clicked you need to fire a Server Side event that will load all the data for each node?
Just to make sure... Do you have AutoPostBack set to true? |
|
#7
|
||||
|
||||
|
maybe I am missing something, but don't you just do the same thing:
Code:
Private Sub cmdExpand_Click()
For k = 1 To TreeView1.Nodes.Count
TreeView1.Nodes(k).Expanded = True
Next k
End Sub
__________________
Mike |
|
#8
|
|||
|
|||
|
Quote:
Node |_______ Node |______ Node |________Node |________Node |________Node |______Node |______Node |_______ Node ect... He would like to expand ALL the nodes from what I understand so you have to drill down through all the child elements for each node. You will have to create a stored procedure that returns all children for each node then populate the tree from that. This will take a while to do tho, I would think about maybe scrapping this idea of expanding all the nodes. I like the idea of closing all nodes tho. very cool... Will |
|
#9
|
|||
|
|||
|
here is the code i think for expanding only a selected node. because expanding the entire tree takes alot of time and might not be need. My code for expanding at one point of the tree works. It works if i specify the node in the actual code.for example Set nodes(1) = Treeview1.nodes(3) but it doesnt work when want it to go from the selected item
Private Sub RepExpTV_Click() Dim nodes(1 To 100) As Object Dim node As Object If TreeView1.SelectedItem Is Nothing Then Exit Sub End If Level = 1 Set nodes(1) = TreeView1.nodes(1).Child While (Level > 0) If nodes(Level) Is Nothing Then Level = Level - 1 If Level = 1 Then Exit Sub Set nodes(Level) = nodes(Level).Next Else Set node = nodes(Level) node.Expanded = True If node.Children > 0 Then Level = Level + 1 Set nodes(Level) = node.Child Else Set nodes(Level) = nodes(Level).Next End If End If Wend |
|
#10
|
|||
|
|||
|
Quote:
on the tree view control put the following oncontextmenu="javascript: showMenu(this); return false;" now here is the function function showMenu(Item) { var NodeSelected = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex); var NodeLevel = new Number(event.treeNodeIndex) var ParentNode = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex).getParent(); var NodeType = ""; var TreeNodeIndex = 0; TreeNodeIndex = new String(NodeSelected.getNodeIndex()); NodeType= new String(NodeSelected.getAttribute("type") ); NodeType= NodeType.toUpperCase(); } Last edited by womalley; July 31st, 2003 at 10:53 AM. |
|
#11
|
||||
|
||||
|
Okay, so then just implement a tree search algorithm which, instead of finding an element, expands the tree!
__________________
Mike |
|
#12
|
|||
|
|||
|
where would i made the changes.. i am doing the change from a menu item// NOT Within by clicking the tree
|
|
#13
|
|||
|
|||
|
Is this the tree view control
Private Sub TreeView1_DblClick() On Error GoTo fokop If TreeView1.SelectedItem.Image = "Arrow" Then TreeView1.StartLabelEdit End If fokop: End Sub |
|
#14
|
|||
|
|||
|
Quote:
on the tree view control put the following oncontextmenu="java script: showMenu(this); return false;" now when the user right clicks on the treeview your menu will show up that part you have done... When the user clicks a menu option you get the NodeIndex that was selected from the following function function showMenu(Item) { var NodeSelected = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex); var NodeLevel = new Number(event.treeNodeIndex) var ParentNode = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex).getParent(); var NodeType = ""; var TreeNodeIndex = 0; TreeNodeIndex = new String(NodeSelected.getNodeIndex()); NodeType= new String(NodeSelected.getAttribute("type") ); NodeType= NodeType.toUpperCase(); } You could even make the variables global by putting then outside the function var NodeSelected = 0; var NodeLevel = 0; var ParentNode = 0; var NodeType = ""; var TreeNodeIndex = 0; function showMenu(Item) { this.NodeSelected = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex); this.NodeLevel = new Number(event.treeNodeIndex) this.ParentNode = document.getElementById(Item.id).getTreeNode(event.treeNodeIndex).getParent(); this.NodeType = ""; this.TreeNodeIndex = 0; this.TreeNodeIndex = new String(NodeSelected.getNodeIndex()); this.NodeType= new String(NodeSelected.getAttribute("type") ); this.NodeType= NodeType.toUpperCase(); } Now when you click on your menu option you will know what the index of the node selected was. If you need to read this from a Server side function, then take the values that you need for that function and put them in a textbox or label. Make sure that visible is set to true or you will not be able to write to it from the client. Once you have the values in the textbox or label you can read them from the server side function/method or sub. I would use a textbox just because it is easier. will |
|
#15
|
|||
|
|||
|
when I right click on my node, I already have a pulldown menu which gives me the option to add items and delete and rename them too. How do I add this new function (of expanding that point on of the node). Thank very much
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|