Click here to Skip to main content
15,503,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone!!

I don´t know how to do this.

I have a treeview, and I want that when I select a child node, automatically the parent node appear selected.

I try the event: "SelectedNodeChanged" but it doesn´t work.

I hope that someone has the answer.

Thank you very much.

1 solution

Normally, the UI paradigm of all tree views assumes that the user selects on node at a time. It looks very natural and clear, and multiple selection mode would be confusing. So, my advise would be not trying to create such tree view style.

However, if you really want something like that, you can find some solution. First of all, people usually use checking instead of selection. For example, see this:[^].

Moreover, as this is a Web application; and tree view is not a native HTML element; instead, ASP.NET generates a tree view based on other HTML elements. So, you can create a different tree view class to develop a very different tree view style; or you can customize available tree view. Please see these CodeProject articles:
C# TreeView with multiple selection[^],
Multi-Select TreeView Control in C#[^].

If you want, you can probably find some more:[^].

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900