Representation of hierarchical data .net winforms

How can I present the following hierarchical data? What control should be used if a possible example helps.

-node -----node1 - -data--data --data -------------node111 -- data -- data -------------node112 -- data -- data -------------node113 -- data -- data -----node2 - -data--data --data -------------node1121 -- data -- data -----node3 - -data--data --data 

and, if possible, I need to put several icons in most cells.

I found this tutorial Link , can someone support me with more information?

Is it possible, if so, how?

Many thanks.

+4
source share
3 answers

The built-in Windows Forms controls are not suitable for this. What you are actually looking for is a hybrid element with a grid tree (a tree with multiple AKA columns or TreeList).

DevExpress has an XtraTreeList that I use (not free) and is probably closest to what you ask, Telerik GridView can also display grid data hierarchically if you set up the groupings correctly.

If these prices are too steep, you can try FlexibleTreeView . Or if you desperately need something for free, check out this CodeProject: Advanced TreeView for.NET page . It will be much more dodgy and difficult to use than commercial products, but it will do the job.

Note that I assume that the data is uniform, that you basically want to display the same data for each node in the hierarchy. If the data is heterogeneous (completely different columns depending on the type of node or level), then you actually want to use a hierarchical GridView. You can get them from the same publishers listed above. I do not know any half-decent free version.

+2
source

Use the TreeView Control

+1
source

One way could be to create a derived TreeNode so that it contains a List<data> :

 // requires declaration of : using System.Windows.Forms; // sample data class public class data { public string Name; public int ID; } public class XTreeNode : TreeNode { List<data> theData = new List<data>(); public XTreeNode(string theNodeID) { this.Text = theNodeID; } public void addData(data newData) { theData.Add(newData); } } 

Here's a (not elegant) example of what an instance of the above data structure (in WinForm) would look like: suppose you have a TreeView named "treeView1" in the form:

  XTreeNode currentNode; data currentData; for (int i = 0; i < 10; i++) { // create the node and add it to the 'treeView1 currentNode = new XTreeNode(i.ToString()); treeView1.Nodes.Add(currentNode); // add some data entries to the List<data> of the derived TreeNode currentData = new data {Name = "one", ID = 100}; currentNode.addData(currentData); currentData = new data { Name = "two", ID = 200 }; currentNode.addData(currentData); currentData = new data { Name = "three", ID = 300 }; currentNode.addData(currentData); // sample of adding a child node currentNode.Nodes.Add(new XTreeNode((i * 100).ToString())); } 

Regarding how you visually display the List<data> associated with each Node: the usual way would be to combine the Treeview with the ListView and synchronize their locations and element heights: then display the List<data> in the same β€œrow” as the corresponding TreeNode

Of course, you can implement your own Node and NodeCollection objects that are completely independent of any control: this example is a mixed case of using a .NET control, which serves as both a data structure and a presentation mechanism.

A great example of the TreeView / ListView combination in CodeProject that has been maintained, updated, and expanded over the years: Phillip Piper: β€œMuch easier to use ListView,” first published in 2006, last updated in October 2009: its functionality is so rich that if compare profitably, imho with commercial components.

+1
source

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


All Articles