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
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.