473,836 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node

I'm building a web application that is analogous to the Windows XP file
explorer in function. The left column contains a TreeView, and the right
column a DataGrid populated by selecting TreeView nodes. The TreeView
populates dynamically as there are a significant number of nodes. The
DataGrid displays both the items and the nodes from the TreeView. Using the
explorer analogy this means the TreeView shows folders, and the DataGrid
folders and files.

The issue I have is that I would like to be able to update the TreeView to
show the selected node if the user selects the matching node from the
DataGrid. Again with the Explorer analogy, if the user selected a folder, the
folder tree would update to match the change. I'm not sure it's possible due
to the dynamic nature of the TreeView in this example as the node may not
even exist in the nodes collection (eg: The TreeView shows the root node plus
1 level but the user has drilled down 3 levels in the DataGrid from the root
node).

Any suggestions?

Kind Regards,
Tim.
Jan 8 '06 #1
2 7504
Hello Tim,

Maybe you could try something like this
Check if a folder item is selected in a datagrid item in the
selectedindexch anged event. If so expand the folder Node in the treeview
with findnode and expand
Treeview1.FindN ode("Authors\\S hakespeare").Ex pand(); or Select

I hope this contributes to a solution.

regards,

Koen Hakvoort

"Tymbow" <Ty****@discuss ions.microsoft. com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
I'm building a web application that is analogous to the Windows XP file
explorer in function. The left column contains a TreeView, and the right
column a DataGrid populated by selecting TreeView nodes. The TreeView
populates dynamically as there are a significant number of nodes. The
DataGrid displays both the items and the nodes from the TreeView. Using
the
explorer analogy this means the TreeView shows folders, and the DataGrid
folders and files.

The issue I have is that I would like to be able to update the TreeView to
show the selected node if the user selects the matching node from the
DataGrid. Again with the Explorer analogy, if the user selected a folder,
the
folder tree would update to match the change. I'm not sure it's possible
due
to the dynamic nature of the TreeView in this example as the node may not
even exist in the nodes collection (eg: The TreeView shows the root node
plus
1 level but the user has drilled down 3 levels in the DataGrid from the
root
node).

Any suggestions?

Kind Regards,
Tim.

Jan 8 '06 #2
That helped. Thanks.

FYI it can be done but it gets a little ugly. Due to the dynamic nature of
the treeview you must remember to use select() and expand() when you change
nodes outside of the tree or things can get very lost. I didn't have much
luck with find node and ended up just iterating the child nodes looking for a
ValuePath match but I'll try to get FindNode working (I hate text matching -
very ugly and requires too much support code to handle unexpected input).

"Koen Hakvoort" wrote:
Hello Tim,

Maybe you could try something like this
Check if a folder item is selected in a datagrid item in the
selectedindexch anged event. If so expand the folder Node in the treeview
with findnode and expand
Treeview1.FindN ode("Authors\\S hakespeare").Ex pand(); or Select

I hope this contributes to a solution.

regards,

Koen Hakvoort

"Tymbow" <Ty****@discuss ions.microsoft. com> wrote in message
news:08******** *************** ***********@mic rosoft.com...
I'm building a web application that is analogous to the Windows XP file
explorer in function. The left column contains a TreeView, and the right
column a DataGrid populated by selecting TreeView nodes. The TreeView
populates dynamically as there are a significant number of nodes. The
DataGrid displays both the items and the nodes from the TreeView. Using
the
explorer analogy this means the TreeView shows folders, and the DataGrid
folders and files.

The issue I have is that I would like to be able to update the TreeView to
show the selected node if the user selects the matching node from the
DataGrid. Again with the Explorer analogy, if the user selected a folder,
the
folder tree would update to match the change. I'm not sure it's possible
due
to the dynamic nature of the TreeView in this example as the node may not
even exist in the nodes collection (eg: The TreeView shows the root node
plus
1 level but the user has drilled down 3 levels in the DataGrid from the
root
node).

Any suggestions?

Kind Regards,
Tim.


Jan 10 '06 #3

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

Similar topics

1
4001
by: ADAM BETCHER | last post by:
Hi: I am using TreeView in a Microsoft Access 2000 form. I can create the tree, populate it and select items. Now I want to Programmatically select and highlight a node on the tree based upon a value selected elsewhere in the form. Can someone explain how to do the above, or send me a reference that explains TreeView in more detail? --
0
1172
by: marian | last post by:
Hi I have changed the control in my form to a Treeview 6 instead of 5 and my code no longer works as before. Can anybody help me here. There are no errors, but I only end up with the first entry (parent) showing and nothing happens with my NodeClick events either. Here is the code to add branches to the tree (taken from somewhere and adapted):-
1
1585
by: UmmagummA | last post by:
Is it possible to select a TreeNode in a TreeView from code? There isn't a property Focused nor a func Focus(). I tried with (all the Nodes are collapsed in this moment): TreeViewObject.SelectedNode = aSpecifiedTreeNode; but it doesn't work. After this assignment SelectedNode remeins <undefined value>.
1
1754
by: Stefan | last post by:
Hey guys ! Can someone pls help me and tell me how it is possible to Select a Node in 2nd row? I got a treeview which is build like follows: node2.Nodes.Add("blah", "blubb"); node1.Nodes.Add(node2);
7
1469
by: CJ Taylor | last post by:
I have the following code. Dim lItem As ListViewItem For Each lItem In Me.lv_Search.Items lItem.Selected = True Next
1
9993
by: James L | last post by:
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.
1
2515
by: Tom | last post by:
Hey, I have a treeview control which i am reading and writing slots to (Its a player manager for Delta Force Black Hawk Down). At the moment, every 100ms it reads through the games memory to retreive the player info, which i can parse. Problem is is that if you have an item selected, when it clears and remakes all the nodes it deselects the one selected, making it pretty useless to select players to view details.
6
11975
by: xla76 | last post by:
I have a simple treeview (treeview1) to which I have added two nodes (nodeA and nodeB) which have n levels of child nodes. What I want is to be able to identify whether the child node I select is under NodeA or NodeB. I can do this by splitting the selectednode.fullpath of the child node but there must be a better way. Can any kind soul can enlighten me?
4
5006
by: frostbb | last post by:
I have a C# WinForms treeview with 20 or so 'level 0' nodes. My users will normally have 2 of the 'level 0' branches open down to a '5th level' selected node. The users will make updates to the 2 selected nodes that will alter the node name. I think I need to rebuild the TreeView to get everything synchronized after they click an update button.
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10602
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
10260
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
9388
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...
0
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5653
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
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.