Support & Community

Owner drawing

Previous Table of Contents Next

You can partially or completely override a node control`s appearance. To do that, you need to inherit your node control class from any core node control and override its appearance as stated below.

Example:

Here we derive our class from the core node control BindableControl (that allows you to bind the node control to a node class`s member) and design our node control appearance manually. Note that this is a very basic sample and you can use the NodePaintBox node control for that purpose.

// The node control for displaying a color rectangle which color is in a node instance.
class MyNodeControl : BindableControl
{
  public MyNodeControl()
  {
    // bind this node control to the Color node property.
    DataFieldName = "Color";
  }
 
  // measure the control`s occupied area size inside a node.
  protected override Size MeasureSize(Node pNode, DrawContext pContext)
  {
    // make static size but you can provide dynamic size as well.
    return new Size(20, 20);
  }
 
  // draw the node control content.
  protected override void Draw(Node pNode, DrawContext pContext)
  {
    Color cl;
 
    cl = GetColor(pNode);
    using (SolidBrush br = new SolidBrush(cl))
    {
      pContext.Graphics.FillRectangle(br, pContext.Bounds);
    }
  }
 
  // get the bound data value.
  Color GetColor(Node pNode)
  {
    return GetValue<Color>(pNode);
  }
}
 
// use our custom node control.
MyNodeControl ctrl = new MyNodeControl();
ctrl.AttachTo(tree);
 
// add nodes.
for(int i = 0; i < 50; i++)
{
  NodeWithColor node = new NodeWithColor();
  // initialize the color that the node control will display.
  node.Color = ((i%3) == 0) ? Color.Red : Color.Green;
  node.AttachTo(tree);
}
 
tree.Options.Node.AutoNodeHeight = true;

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.