Support & Community

Nodes. Get started.

Previous Table of Contents Next

The treeview may consist of one or many nodes. Every node shows data of one node class (ARMSoft.FlexibleTreeView.Node or inherited from it) instance.

Node controls inside a node


Every node consists of node controls added to the treeview which are bound to node class`s members (properties or fields).

Treeview structure



Treeview root node

The treeview has one root and invisible node, accessible in the Root property. The root node is the parent of all root–level nodes and you can`t delete or hide it. Flexible TreeView provides quick access to all root–level nodes through the Nodes property.


Row index

Every visible node has its own unique index (row index) in the treeview, starting from 0 for the first, top node. This index is stored in the Row property and is used to identify and find the node in the tree.

Node row index



Children nodes

Every node may have an unlimited children nodes count, stored in the Nodes property.


Creation

You can add node of any type, inherited from the Node class, to the treeview simultaneously. This allows you to bind one node control to different data or data types in these nodes.

Example:

abstract  class DiskObjectNode : Node
{
  public abstract string ObjectType { get; }
}
 
class FileNode : DiskObjectNode
{
  public override string ObjectType { get { return "File"; } }
}
 
class DirectoryNode : DiskObjectNode
{
  public override string ObjectType { get { return "Directory"; } }
}
 
// add node controls to show the object name and type (file or directory).
NodeTextBox objectName = new NodeTextBox();
// bind to the built-in node property.
objectName.DataFieldName = "Text";
objectName.AttachTo(tree);
 
NodeTextBox objectType = new NodeTextBox();
// bind to the virtual property with different content according to the node type.
objectType.DataFieldName = "ObjectType";
objectType.AttachTo(tree);
 
// add nodes of different types.
DirectoryNode folder = new DirectoryNode();
folder.Text = "Windows";
folder.AttachTo(tree);
 
FileNode fn=new FileNode();
fn.Text = "autoexec.bat";
fn.AttachTo(folder);


Node auto-height

Flexible TreeView allows you to create a dynamic and flexible UI, so any node may have a different height depending on its content. To completely show these nodes, you need to enable the node auto-height calculation by enabling the Options.Node.NodeAutoHeight treeview property; otherwise, all those nodes` content would be cropped. If you want to show nodes with already established heights, you can disable the NodeAutoHeight property and set the node`s static height in the PreferredNodeHeight treeview property. It will greatly increase treeview performance.


Built–in custom node classes

As well as the standard Node class, Flexible TreeView has many built-in custom node classes that allows you to easily use them with appropriate node controls:

  • NodeWithDescription – defines a node with the Description text property to use with expandable node controls like a NodeExpandableTextBox;
  • NodeWithImage – defines a node with the Image property to use with the NodeImage node control;
  • NodeWithAnimImage – defines a node with the Animation property to use with the NodeImage node control when animation is enabled;
  • NodeWithColor – defines a node with the Color property of the type System.Drawing.Color to use with the NodeColorPicker node control to select a solid color;
  • NodeWithGradient – defines a node with the Color property of the type ARMSoft.FlexibleTreeView.Themes.ColorGradient to use with the NodeColorPicker node control to select a color gradient;
  • NodeWithControl – defines a node with the Container property to use with the NodeControlContainer node control;
  • NodeWithLink – defines a node with the Link property to use with the NodeLink node control.



Find node in the treeview

In many cases, you need to find a node in the treeview. Flexible TreeView has these built–in methods for that purpose:

  • GetNodeAt – find a node by location;
  • GetNodeByRow – find a node by the row number;
  • GetNodeBounds – get a node bounds rectangle.



API reference

Properties

  • Text - node title text;
  • Nodes - children nodes list;
  • Parent - parent node. Returns NULL for any root-level node;
  • RealParent - parent node. Identical to the Parent property, but returns treeview`s Root node for all root-level nodes;
  • CheckState - node check state;
  • IsAttached - a boolean value, indicating whether this node is attached not a treeview;
  • TreeView - treeview, to which this node is bound;
  • Root - treeview`s root node;
  • Index - zero–based node index within the current parent node;
  • Level - nesting level, where 0 is the root node, 1 is the root`s children node and so on;
  • Path - contains all node`s parents.

Previous Top Next

Last news
Flexible TreeView v2.7
Sunday, 01 August 2010

Flexible TreeView v2.7 has been released with completely reimplemented data binding support.

Flexible TreeView v2.6
Thursday, 13 May 2010
Flexible TreeView v2.6 has been released with Visual Studio 2010 support, new NodeDateTime node control, data access great speed increase and much more.
Flexible TreeView v2.5
Saturday, 13 March 2010

Flexible TreeView v2.5 has been released with the new NodeProgressBar node control.

Latest release

Version:
Release date:
2.7.1
Aug 11, 2010


Copyright © 2006-2010 ARMSoft. All rights reserved.