473,394 Members | 1,785 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,394 software developers and data experts.

expand a treeview at a particular node

Sam
Hi,
Say I have the following Treeview :

N1
|-N11
|-N12
|-N121
|-N122
N2
|-N21
|-N22
|-N221
|-N222
N3

N1, N2 and N3 are collapsed so my tree is enterely collapsed.
Now if N2 is expanded and N222 is selected, when the user clicks on a
button that should delete N222 and the tree should be refreshed and
expanded to N221, which is the previous node (if there was no previous
node, then N22 would be selected - only Nxxx nodes can be deleted).
I know how to get the level of a node :

While Not node Is Nothing
node = node.Parent
level += 1
End While

as well as its index. But N222 and N122 have the same level and index,
so how can I know to which node I should expand my tree ?

Some code would be very welcome !

Thx for your help.

Sam

Nov 21 '05 #1
2 1805
Hi,

With node.parent
.EnsureVisible ' make sure the node is visible
.Expand ' Show all of it children
end with

http://msdn.microsoft.com/library/de...xpandtopic.asp

http://msdn.microsoft.com/library/de...sibletopic.asp
Ken
------------------
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,
Say I have the following Treeview :

N1
|-N11
|-N12
|-N121
|-N122
N2
|-N21
|-N22
|-N221
|-N222
N3

N1, N2 and N3 are collapsed so my tree is enterely collapsed.
Now if N2 is expanded and N222 is selected, when the user clicks on a
button that should delete N222 and the tree should be refreshed and
expanded to N221, which is the previous node (if there was no previous
node, then N22 would be selected - only Nxxx nodes can be deleted).
I know how to get the level of a node :

While Not node Is Nothing
node = node.Parent
level += 1
End While

as well as its index. But N222 and N122 have the same level and index,
so how can I know to which node I should expand my tree ?

Some code would be very welcome !

Thx for your help.

Sam
Nov 21 '05 #2
Sam
actually it seems to work by doing :

tvMain.SelectedNode = m_savedNode (m_savedNode being the node that was
previously selected before collapsing the tree) Now since m_savedNode
is meant to be deleted, I have to figure out how to select the previous
node (or that node's parent)

Nov 21 '05 #3

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

Similar topics

4
by: Gönen EREN | last post by:
how can i collapse or expand a node of treeview control programmaticly? thanks.
2
by: Stephen | last post by:
In asp.net 1.1, the IE treeview web control has a property called "SelectExpands" that, when set to true, expands a node when a user clicks the node text. I can't seem to replicate this in the...
4
by: Karim El Jed | last post by:
Hi, I'm trying to expand a special Node of my TreeView from Codebehind. I have a TreeView on a page for navigating to another site. On the other tsite here is the same TreeView more precisely a...
1
by: SamSpade | last post by:
I want to expand nodes on a treeview. What I have is an array (SubFolder) of node.text not index. What I'd like to do is the folowing: lKey = tvFolders.Nodes(0) ) 'Not in SubFolder For...
3
by: Sam | last post by:
Hi, I'd like to select a node in my code and expand that node. How can I do the selection ? How can I expand it once I've selected the node ? Thx
0
by: Shadow Lynx | last post by:
When using ASP.NET 2.0's built-in TreeView on a page with <BASE target = "AnythingBut_Self"></BASE> in the HEAD, the expand/collapse buttons fail to function. The reason for this is that the...
4
by: Alan T | last post by:
Is it possible or is there a method for a treeview to expand down to the node by giving the node? Eg. I was given a node say at level 3 and would like to expand at that node.
0
by: jim | last post by:
Hi, I have a TreeView control that sits on the MasterPage. All of my other webpages inherit from that Master Page. The Treeview receives it's data using an XMLDataSource that has it's DataFile...
4
by: Marcolino | last post by:
Hi I have a little problem with Treeview expand. So I'll try to explain. I Have one node and some subnodes like this +Nodes1 |------Subnodes 1 |------Subnodes 2 +Nodes2
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.