Flexible TreeView Flexible TreeView


Support & Community

NodePaintBox node control

Previous Table of Contents Next

If you need to display data that has no built-in node control supports, you can display it manually using the NodePaintBox node control.
Using of the NodePaintBox node control involves these steps:

  • Measure the node control size inside a node using the MeasureNodeControl treeview event;
  • Draw data using the PaintNodeControl treeview event.

Example:

// create the node control.
NodePaintBox nc = new NodePaintBox();
nc.AttachTo(tree);
// subscribe to the event to define the node control`s size and content.
tree.MeasureNodeControl += tree_MeasureNodeControl;
tree.PaintNodeControl += tree_PaintNodeControl;
 
// add nodes, where our data will be displayed.
Node n = new Node("1");
n.AttachTo(tree);
n = new Node("2");
n.AttachTo(tree);
 
private void tree_MeasureNodeControl(FlexibleTreeView pTreeview, MeasureObjectEventArgs pArgs)
{
  // measure the node control size according to the specified node
  switch(pArgs.Node.Text)
  {
    case "1":
      pArgs.Size = new Size(20, 20);
      break;
 
    case "2":
      pArgs.Size = new Size(30, 30);
      break;
  }
}
 
// paint the node control content as a red rectangle.
void tree_PaintNodeControl(FlexibleTreeView pTreeview, NodeControlDrawEventArgs pArgs)
{
  using (Brush br = new SolidBrush(Color.Red))
  {
    pArgs.Context.Graphics.FillRectangle(br, pArgs.Context.Bounds);
  }
}

Previous Top Next


Last news
Bookmark and Share
Use Flexible TreeView in WPF project
Sunday, 18 December 2011

Do you have a WPF project and want to use Flexible TreeView there? No problem!

Flexible TreeView v3.4
Friday, 16 December 2011

Flexible TreeView v3.4 maintenance release has been released.

Flexible TreeView v3.3
Friday, 23 September 2011

Flexible TreeView v3.3 maintenance release has been released. Separate assemblies for .NET 2.0, 4.0 and 4.0 Client Profile, HTML markup extension, etc.

Latest release

Version:
Release date:
3.4
Dec 16, 2011


Copyright © 2006-2012 ARMSoft. All rights reserved.