Profile Picture

Populate NTreeList Help

Posted By Vince McMullin 14 Years Ago
Author
Message
Vince McMullin
Posted 14 Years Ago
View Quick Profile
Junior Member

Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)Junior Member (18 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 18, Visits: 2
Hello,

I am trying to populate the NTreeList so I have an organized tree structure to multiple root and child node series. I have populated the Columns and the Root Node but when trying to add subitems I have not been successful. Can someone please explain to me how I can add a root node and then populate that root node with child nodes which populates the listview subitems as well.


namespace test2
{
public partial class Form1 : Form
{
private NTreeNode[] node = new NTreeNode[3];

public Form1()
{
InitializeComponent();
addColumns();
populateRootNodes();
//populateSubNodes();
}

private void addColumns()
{
NTreeListColumn column = new NTreeListColumn();
column.Header.Text = "Dataset";
column.Width = 250;
nDataExplorer.Columns.Add(column);

column = new NTreeListColumn();
column.Header.Text = "Station ID";
column.Width = 250;
nDataExplorer.Columns.Add(column);

column = new NTreeListColumn();
column.Header.Text = "Station Name";
column.Width = 250;
nDataExplorer.Columns.Add(column);

column = new NTreeListColumn();
column.Header.Text = "Station Type";
column.Width = 250;
nDataExplorer.Columns.Add(column);

column = new NTreeListColumn();
column.Header.Text = "Province";
column.Width = 250;
nDataExplorer.Columns.Add(column);

column = new NTreeListColumn();
column.Header.Text = "Samples";
column.Width = 250;
nDataExplorer.Columns.Add(column);
}

private void populateRootNodes()
{
NTreeListColumn column = nDataExplorer.Columns[0];
NTreeListColumn column1 = nDataExplorer.Columns[1];
NTreeNodeCollection children = nDataExplorer.Nodes;

//TreeNodeCollection result = new TreeNode().Nodes;

node[0] = new NTreeNode();
node[0].Text = "Surface Water Quality";
node[1] = new NTreeNode();
node[1].Text = "Pulp Mill Water Quality";
node[2] = new NTreeNode();
node[2].Text = "asdasdasd";
children.AddRange(node);

}

private void populateSubNodes()
{
NTreeListColumn column = nDataExplorer.Columns[0];

NTreeListNode node2;
NTreeListNodeStringSubItem item;


node2 = new NTreeListNode();
node2.ExpandCollapseMode = TreeNodeExpandCollapseMode.Always;

item = new NTreeListNodeStringSubItem();
item.Text = "test";
item.Column = column;

}

}
}


Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hello Vince,

Please, check the code snipped bellow. It should give you a good picture of the NTreeList's nodes and subitems structure:

NTreeListColumn column1 = new NTreeListColumn();
column1.Header.Text =
"Column 1";
nTreeList1.Columns.Add(column1);

NTreeListColumn column2 = new NTreeListColumn();
column2.Header.Text =
"Column 2";
nTreeList1.Columns.Add(column2);

NTreeListNode node1 = new NTreeListNode();
nTreeList1.Nodes.Add(node1);

NTreeListNodeStringSubItem textSubItem1 = new NTreeListNodeStringSubItem("TextSubItem1");
textSubItem1.Column = column1;
node1.SubItems.Add(textSubItem1);

NTreeListNodeNumericSubItem numernicSubItem1 = new NTreeListNodeNumericSubItem();
numernicSubItem1.Value = 20;
numernicSubItem1.Column = column2;
node1.SubItems.Add(numernicSubItem1);

NTreeListNode node11 = new NTreeListNode();
node1.Nodes.Add(node11);

NTreeListNodeStringSubItem textSubItem11 = new NTreeListNodeStringSubItem("TextSubItem 11");
textSubItem11.Column = column1;
node11.SubItems.Add(textSubItem11);

NTreeListNodeNumericSubItem numernicSubItem11 = new NTreeListNodeNumericSubItem();
numernicSubItem11.Value = 30;
numernicSubItem11.Column = column2;
node11.SubItems.Add(numernicSubItem11);

Basically, you should describe the treelike structure with the nodes, as each node has Nodes collection.

The content of the control should be described by the subitems. Each node has SubItems collection, and the content of each subitem will be displayed depending on the value of Column property.

I hope this will help you to get the idea of the NTreeList structure.

If you have any difficulties, please do not hesitate to ask.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic