NodeExpandablePanel
The NodeExpandablePanel node control is identical to the NodeExpandableTextBox node control, but displays any custom content instead of a description part when the mouse hovers over the node.
To use it, subscribe to the MeasureNodeControlCustomArea and PaintNodeControlCustomArea treeview events to measure and draw an expandable area respectively, as shown below.
// Create the node control.
NodeExpandablePanel name = new NodeExpandablePanel();
name.AttachTo(tree);
// Add a node with the title and custom drawing area.
NodeWithDescription node = new NodeWithDescription();
node.Text = "John Smith";
node.AttachTo(tree);
// Prepare treeview for auto-expanding.
tree.Options.Node.AutoNodeHeight = true;
tree.Options.Selection.HoverStyle = eHoverStyle.SoftSelect;
// Attach event handlers to paint the expanded area.
tree.MeasureNodeControlCustomArea += tree_MeasureNodeControlCustomArea;
tree.PaintNodeControlCustomArea += tree_PaintNodeControlCustomArea;
// Measure our node control's size.
void tree_MeasureNodeControlCustomArea(FlexibleTreeView treeview, MeasureObjectEventArgs args)
{
args.Size = new Size(20, 20);
}
// Draw our node control.
private void tree_PaintNodeControlCustomArea(FlexibleTreeView treeview, NodeControlDrawEventArgs args)
{
Rectangle bounds;
// Draw the 20x20 red rectangle.
bounds = args.Context.Bounds;
bounds.Size = new Size(20, 20);
using (Brush br = new SolidBrush(Color.Red))
{
args.Context.Graphics.FillRectangle(br, bounds);
}
}
' Create the node control.
Dim name As New NodeExpandablePanel()
name.AttachTo(tree)
' Add a node with the title and custom drawing area.
Dim node As New NodeWithDescription()
node.Text = "John Smith"
node.AttachTo(tree)
' Prepare treeview for auto-expanding.
tree.Options.Node.AutoNodeHeight = True
tree.Options.Selection.HoverStyle = eHoverStyle.SoftSelect
' Attach event handlers to paint the expanded area.
AddHandler tree.MeasureNodeControlCustomArea, AddressOf tree_MeasureNodeControlCustomArea
AddHandler tree.PaintNodeControlCustomArea, AddressOf tree_PaintNodeControlCustomArea
' Measure our node control's size.
Private Sub tree_MeasureNodeControlCustomArea(treeview As FlexibleTreeView, args As MeasureObjectEventArgs)
args.Size = New Size(20, 20)
End Sub
' Draw our node control.
Private Sub tree_PaintNodeControlCustomArea(treeview As FlexibleTreeView, args As NodeControlDrawEventArgs)
Dim bounds As Rectangle
' Draw the 20x20 red rectangle.
bounds = args.Context.Bounds
bounds.Size = New Size(20, 20)
Using br As Brush = New SolidBrush(Color.Red)
args.Context.Graphics.FillRectangle(br, bounds)
End Using
End Sub