By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

ASP.NET 2.0 TreeView - Programatically Selecting A TreeView Node

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
Hello Tim,

Maybe you could try something like this
Check if a folder item is selected in a datagrid item in the
selectedindexchanged event. If so expand the folder Node in the treeview
with findnode and expand
Treeview1.FindNode("Authors\\Shakespeare").Expand( ); or Select

I hope this contributes to a solution.

regards,

Koen Hakvoort

"Tymbow" <Ty****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.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

P: n/a
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
selectedindexchanged event. If so expand the folder Node in the treeview
with findnode and expand
Treeview1.FindNode("Authors\\Shakespeare").Expand( ); or Select

I hope this contributes to a solution.

regards,

Koen Hakvoort

"Tymbow" <Ty****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.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 discussion thread is closed

Replies have been disabled for this discussion.