Skip to content

NodeButton

NodeButton node control allows you to display a button control inside a node and handle its clicks.

Example

// 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
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 you 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 you 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
    Public Property 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 holds 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.

Example

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 you 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 you 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 piece of Flexible TreeView, NodeButton allows you 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:

  • NCButtonTextEnabled
  • NCButtonTextEnabledInactive
  • NCButtonTextEnabledSelected
  • NCButtonTextEnabledSelectedInactive
  • NCButtonTextEnabledFocused
  • NCButtonTextEnabledFocusedInactive
  • NCButtonTextEnabledHot
  • NCButtonTextEnabledHotInactive
  • NCButtonTextDisabled
  • NCButtonTextDisabledSelected
  • NCButtonTextDisabledFocused
  • NCButtonTextDisabledHot

Note

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