Appearance customization

Generally, Flexible TreeView allows you to define the node control appearance for all nodes at one time. To define a different node control appearance for each node, you need to override the following node control methods:

  • GetFont - to change the node control font for each node.
  • GetTextColor - to change the node control's text color for each node.
  • GetTitleFont - to change the expandable node control's title font.
  • GetTitleColor - to change the expandable node control's title color.
  • GetDescriptionFont - to change the NodeExpandableTextBox's description font.
  • GetDescriptionColor - to change the NodeExpandableTextBox's description color.

To do this, inherit your new node control class from the built-in one, override one of these methods, and install this node control into a treeview as shown below:

// The node control that displays bold text when the node is selected or focused.
class MyNodeTextBox : NodeTextBox
{
    public override Font GetFont(Node node, DrawContext context)
    {
        Font font = base.GetFont(node, context);
        if (node.IsSelected)
        {
            font = new Font(font, FontStyle.Bold);
        }
        return font;
    }
}

// Use our new node control.
MyNodeTextBox tb = new MyNodeTextBox();
tb.AttachTo(tree);
' The node control that displays bold text when the node is selected or focused.
Class MyNodeTextBox
    Inherits NodeTextBox
    Public Overrides Function GetFont(node As Node, context As DrawContext) As Font
        Dim font As Font = MyBase.GetFont(node, context)
        If node.IsSelected Then
            font = New Font(font, FontStyle.Bold)
        End If
        Return font
    End Function
End Class

' Use our new node control.
Dim tb As New MyNodeTextBox()
tb.AttachTo(tree)