473,659 Members | 3,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView - Reloading the treeView and expanding the last selected

Hi,

I have a treeview that has to be refreshed due to data changes. Is it
possible to select the last node that they were viewing when the tree view
was been populated once again?

I have tried getting the selected node and then expanding it in the
refreshed tree view using expand() but it does not do it.

Thanks for any help.
Dec 5 '05 #1
1 9962
Are you clearing out the tree when you fresh it, or just updating the
existing nodes without removing them?

If you clear the nodes from the tree, then the selected node no longer
exists and therefore you cannot expand it. In this case you will need a path
to follow up the tree to the root, then once the tree is refreshed, you will
need to follow this path back down from the root to find the node that should
be selected and then select and expand it. Determining how you will find a
path to follow is dependent on the data stored in the tree and how it is
stored.

If you are just refreshing the existing nodes, create a TreeNode reference
and set it equal to the TreeView.Select edNode before refreshing, then once
refreshed use the TreeNode.Expand () method from the reference you made.

private void BeginRefreshTre eView()
{
TreeNode selected = TreeView.Select edNode();
this.RefreshTre eView();
selected.Expand ();
}

private void RefreshTreeView ()
{
//Do your refresh (make sure not to remove the nodes though)
}

If this doesn't help, please post an example of what is stored in the tree
and how you are refreshing it.

Chris

"James L" wrote:
Hi,

I have a treeview that has to be refreshed due to data changes. Is it
possible to select the last node that they were viewing when the tree view
was been populated once again?

I have tried getting the selected node and then expanding it in the
refreshed tree view using expand() but it does not do it.

Thanks for any help.

Dec 5 '05 #2

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

Similar topics

2
1354
by: clsmith66 | last post by:
In a treeview, I am trying to store the index of every treenode as it expands in a hidden input box. If I click on the node itself, it expands and I can capture the node index no problem. If I click on the plus sign however, the selected index doesn't change so I can't capture the index of the newly expanded node. Does any one know how to change the selected node when a plus sign is clicked?
4
10129
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 new TreeView with the same nodes ;) So I would like to keep the expanding state of the first Tree for the second one on the next page. At least the last selected node (path will be saved in query string) should be expanded.
7
2827
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made of custom, extended nodes, which include all the extra information contained in the table and not just typical TreeNode objects. To do that, I first created a structure with all the extra
2
2389
by: James L | last post by:
I have finally developed some code that allows you to re populate a tree view and re select the last node that was clicked. However, you have to hard code it for the number of levels the tree view could possibly be expanded to. Any ideas? //The test program has a button to set the path and a button to execute the path finding code. //This is so that you can close the treeview back up to the root to ensure the correct code is selected
2
9786
by: Claus | last post by:
Hello, I have a long treeview with scrollbars. When I scroll down and press a treeview node, then the Load event fires and navigate in an iframe to another page. The problem is, that afterwards the treeview is collapsed and the node isn't selected. Expanding and selecting the node via code in the load event works, but how do I achieve, that the treeview scrolls down to the selected node? Thanks for any help Claus
1
4920
by: doemon | last post by:
Hi, I'm working on a pagination control and I need to dynamically rerender a treeview to display the next set of nodes depending on which page we're on. For example, page 1 will dispaly only nodes 1 to 10, but when the user clicks , the tree will display nodes 11 to 20. Page 1 will is loaded when the page that contains the ascx (parent of the treeview) is loaded. This is all cool. The treeview displays correctly. When I click the ...
1
1495
by: Rick | last post by:
Hi guys! I have a problem with a master page that has a treeview control as menu, i have a root node, 5 parents and each parent has 10 leafs, 50 pages in total, each page is linked to master page, when i select a node in treeview it redirects to N page, its ok, but i want each time i select a page in the treeview it expand the tree to current node selected, i can't do it, each time i select a node, treeview appears as originally i...
26
8510
by: JJ | last post by:
Is there any way you can expand a parent node on the treeview control _without a postback_ by clicking on the node text (NOT clicking the expand image URL) ? I want to format the treeview node to look like a column of buttons that expand to show the child nodes (if there are child nodes) qithout a postback. I don't want to display the plus/minus or any other expand/collapse graphic. ?
1
1639
by: Rohit111111 | last post by:
Hello all, I have a treeview control just like windows file structure.I have a treeview control on the left side of page that will populate from database upto n-level,and on click of any node i am showing sub categories and files of selected category from the treenode,and on the right side of page i have a link add category that will redirect the user to new page where user can add new category.and this new category is added in the category...
0
8337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.