Customization
In case you are not satisfied with the provided column controls, it is easy to create a custom column control manually.
Flexible TreeView provides a couple of ways to implement custom column controls:
- Use the ButtonColumnControl base class to create a column control that looks like a dropdown button shown in the column header but has custom behavior when clicked.
- Use the TreeColumnControl base class to create a completely new column control. It may have a different look and behavior.
The first approach is recommended for most needs and switch to the second one when you really need to create something very unique, as it will involve some coding.
Inheriting ButtonColumnControl#
The ButtonColumnControl base column control class provides the basic functionality to display a button with an optional dropdown arrow and an icon, and allows handling button clicks.
Particularly, when deriving from the ButtonColumnControl class, the descendant class should override the HandleButtonClick method and perform any desired action. The HandleButtonClick method is called each time the column control's button is clicked. By examining the args
passed parameter, you can determine the mouse state when clicked.
Below is a sample ClickableColumnControl column control that shows a message when the column control is clicked.
class ClickableColumnControl : ARMSoft.FlexibleTreeView.Column.Controls.ButtonColumnControl
{
protected override void HandleButtonClick(MouseActionArgs args, DrawContext context)
{
MessageBox.Show("The button was clicked!");
}
}
// Create a column for the column control.
TreeColumn column = new TreeColumn("Action");
tree.Columns.Add(column);
// Add column control to the column.
ClickableColumnControl columnControl = new ClickableColumnControl();
column.Controls.Add(columnControl);
Class ClickableColumnControl
Inherits ARMSoft.FlexibleTreeView.Column.Controls.ButtonColumnControl
Protected Overrides Sub HandleButtonClick(args As MouseActionArgs, context As DrawContext)
MessageBox.Show("The button was clicked!")
End Sub
End Class
' Create a column for the column control.
Dim column As New TreeColumn("Action")
tree.Columns.Add(column)
' Add column control to the column.
Dim columnControl As New ClickableColumnControl()
column.Controls.Add(columnControl)
By changing the Image and ShowDropDownArrow properties of the ButtonColumnControl, you can modify the column control's behavior and appearance.