Mapping a TreeView node in winform

I have a treeview control and its child element node is displayed in an element in the list, when the element in the list state changes, I need to update the corresponding node tree, also when the user selects treenode, I can map the element in the list, what is the best way to write display?

+3
source share
2 answers

If this is standard WinForms TreeView, you can use the tag property on each node to maintain a link to the corresponding list item.

If you also use ListView, each ListViewItem also has a tag property that can be used to reference the corresponding treenode.

Using the Tag property of both TreeNodes and ListVIewItems allows you to easily implement two-way synchronization between them.

These tag properties have an object of type, so you can store everything you need. In your case, when the user edits the ListViewItem, you first get the Tag property, pass it to the TreeNode object, and update the state of the TreeNode as necessary.

The same process otherwise applies when the user edits the TreeNode element.

[Update]

Tree Control List, , . Windows Forms TreeView ListView ( List) , . . Tag / .

+3

, TreeView Winforms, http://updatecontrols.net/ - , . .

+1

Source: https://habr.com/ru/post/1726107/


All Articles