Flexible TreeView 5.1.9 Help
NodeButton node control

NodeButton node control allows to display a bindable button inside a node and handle clicks on it. The NodeButton node control can be added to the treeview using Visual Studio Windows Forms designer or explicitly in code.

To add the NodeButton node control using Visual Studio Windows Forms designer open the treeview's Properties window, open the NodeControls property editor, click the Add dropdown button and select NodeButton menu item.

To add the NodeButton in code use the sample code below:

// define a custom node type that holds the button title.
class ButtonNode : Node
{
  public string ButtonTitle { get; set; }
}
 
// add the node control, bind it to the ButtonNode.ButtonTitle string property.
NodeButton btn = new NodeButton();
btn.DataFieldName = "ButtonTitle";
btn.AttachTo(tree);
 
//  add the node.
ButtonNode node = new ButtonNode();
node.ButtonTitle = "Click me!";
node.AttachTo(tree);
' define a custom node type that holds the button title.
Class ButtonNode
    Inherits Node
    Public Property ButtonTitle() As String
        Get
            Return m_ButtonTitle
        End Get
        Set
            m_ButtonTitle = Value
        End Set
    End Property
    Private m_ButtonTitle As String
End Class

' add the node control, bind it to the ButtonNode.ButtonTitle string property.
Dim btn As New NodeButton()
btn.DataFieldName = "ButtonTitle"
btn.AttachTo(tree)

'  add the node.
Dim node As New ButtonNode()
node.ButtonTitle = "Click me!"
node.AttachTo(tree)

 

Data binding

NodeButton node control is a usual bindable Flexible TreeView's node control. It allows to bind the button title to a node class's property which name is specified in the DataFieldName property as shown above.
Also, NodeButton allows to bind the shown button's size value to the node class's property which name is specified in the SizeDataFieldName property. The bound property should be of the System.Drawing.Size type as shown below.

class ButtonNode : Node
{
  public string ButtonTitle { get; set; }
  public Size ButtonSize { get; set; }
}
 
NodeButton btn = new NodeButton();
btn.DataFieldName = "ButtonTitle";
btn.SizeDataFieldName = "ButtonSize";
btn.AttachTo(tree);
 
ButtonNode node = new ButtonNode();
node.ButtonTitle = "Click me!";
node.ButtonSize = new Size(100,30);
node.AttachTo(tree);
Class ButtonNode
    Inherits Node
    Public Property ButtonTitle() As String
        Get
            Return m_ButtonTitle
        End Get
        Set
            m_ButtonTitle = Value
        End Set
    End Property
    Private m_ButtonTitle As String
    Public Property ButtonSize() As Size
        Get
            Return m_ButtonSize
        End Get
        Set
            m_ButtonSize = Value
        End Set
    End Property
    Private m_ButtonSize As Size
End Class

Dim btn As New NodeButton()
btn.DataFieldName = "ButtonTitle"
btn.SizeDataFieldName = "ButtonSize"
btn.AttachTo(tree)

Dim node As New ButtonNode()
node.ButtonTitle = "Click me!"
node.ButtonSize = New Size(100, 30)
node.AttachTo(tree)

In case there is no node class property that hold the desired button's text or if you need to display the same text in all shown buttons for all available treeview nodes you can use the StaticValue property. By assigning it only once, as shown below, all shown buttons will use its value as the button text instead of retrieving it from a property which name is specified in the DataFieldName property.

NodeButton btn = new NodeButton();
btn.StaticValue = "Click me!";
btn.AttachTo(tree);
Dim btn As New NodeButton()
btn.StaticValue = "Click me!"
btn.AttachTo(tree)

 

StaticSize

By default, NodeButton adjusts the button size dynamically by using either the SizeDataFieldName property or by measuring the button bound text as described above in the 'Data binding' section.
If you need to display the buttons of the same size for all nodes you can set the desired button size in pixels using the StaticSize property.


HTML tags support

NodeButton supports all the HTML tags like other text node controls using the SupportHtml property as shown below.

NodeButton btn = new NodeButton();
btn.DataFieldName = "Text";
btn.SupportHtml = true;
btn.AttachTo(tree);
 
Node node = new Node();
node.Text = "<b>Bold</b> text";
node.AttachTo(tree);
Dim btn As New NodeButton()
btn.DataFieldName = "Text"
btn.SupportHtml = True
btn.AttachTo(tree)

Dim node As New Node()
node.Text = "<b>Bold</b> text"
node.AttachTo(tree)

 

Text trimming

By changing the Trimming property that is of ARMSoft.FlexibleTreeView.eStringTrimming type NodeButton allows to trim the button's long text. To trim the text with '...' characters use the eStringTrimming.EllipsisCharacter value, to disable trimming use the eStringTrimming.None value.


Text wrapping

By changing the TextWrapMode property that is of ARMSoft.FlexibleTreeView.eTextWrapMode type NodeButton allows to wrap the button's long text to the next line by splitting it by the specified pattern. By setting TextWrapMode to eTextWrapMode.WordWrap value NodeButton will split the button text by the whitespace character.
To disable text wrapping set the TextWrapMode property to eTextWrapMode.Disabled value.


ContentAlign

As other node controls, NodeButton supports its content alignment within the available column space using the ContentAlign property. Read this topic for details.


Theme overriding

As any other peace of Flexible TreeView, NodeButton allows to override its color theme to create a look that is appropriate for your application's style.
Read this topic for details about how to override the node control's particular colors. Use the specific ARMSoft.FlexibleTreeView.Themes.eColor values shown below to change the NodeButton colors:

Note that the theme overriding will be taken into account by all themes except the System theme.

 

 


Copyright © 2006-2016 ARMSoft

www.FlexibleTreeView.com