Focusing on Parent and child nodes within Tree View control

John 506 Reputation points
2023-02-17T20:06:22.19+00:00

I am trying to learn a new control, a Tree View control.

I would like to know more about how it works, for example, when users click on a parent or child node, it triggers an event or outcome within a separate control.

Which Tree View properties include those parent and child nodes?

Do users have to instantiate them first?

Here are some screenshots:

Main Interface with Tree View Control

Tree View Properties

Hopefully, most users who are familiar with using this control would be able to respond at their earliest convenience.

I am unsure if I would need to instantiate the parent or child nodes first.

Regards,

John

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-02-20T06:35:58.92+00:00

    Hi John, Welcome to Q&A.

    For TreeNode view control, you can check this documentation, inside There are detailed explanations.

    The key properties of the TreeView control are Nodes and SelectedNode. The Nodes property contains the list of top-level nodes in the tree view. The SelectedNode property sets the currently selected node. You can display icons next to the nodes. The control uses images from the ImageList named in the tree view's ImageList property. The ImageIndex property sets the default image for nodes in the tree view.

    You have two ways to add nodes to TreeNode view. They are also described in the documentation.

    The first one, you can directly edit the control on the design interface , there is no need to consider the instantiation problem here.

    Second, if you add nodes programmatically, You do need to instantiate them. And you need to have a parent node before you can create a child node.

    The events for TreeNode View are in here.

    For nodes, you need to create delegated events for them individually, to achieve events like clicking on a specific node.

    Best Regards, Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.