NodeCheckBox
The NodeCheckBox node control allows you to show a checkbox or radio button icon inside a node.
Note
NodeCheckBox displays only an image of a checkbox or radio button, without any text. To show text, additionally add the NodeTextBox node control after the NodeCheckBox.
NodeCheckBox can be bound to a property of either bool
, Nullable<bool>
or ARMSoft.FlexibleTreeView.Nodes.eCheckState
data types.
To specify what check type, checkbox or radio button, will be displayed, use the CheckType node property (eCheckType.CheckBox value by default).
By default, NodeCheckBox instance is bound to the node's check state that is stored in CheckState node property of type ARMSoft.FlexibleTreeView.Nodes.eCheckState
.
Example
Change check state in event handler#
By default, NodeCheckBox node control is bound to the node's CheckState property. If you need to override the check state value from an event handler in runtime, assign the new check state and enable the args.Handled property to skip the default check state change logic.
Example
// the node control instance to access it from the event handler later.
NodeCheckBox checkBox;
// create the node control.
checkBox = new NodeCheckBox();
checkBox.AttachTo(tree);
// create the node.
Node node = new Node();
node.AttachTo(tree);
tree.MouseDown += tree_MouseDown;
// process the mouse click on a node.
void tree_MouseDown(FlexibleTreeView treeview, MouseActionArgs args)
{
if (args.NodeControl == checkBox)
{
// change the check state manually
args.Node.CheckState = checkBox.GetNextCheckState(args.Node);
// and skip all further processing for this event.
args.Handled = true;
}
}
' the node control instance to access it from the event handler later.
Private checkBox As NodeCheckBox
' create the node control.
checkBox = New NodeCheckBox()
checkBox.AttachTo(tree)
' create the node.
Dim node As New Node()
node.AttachTo(tree)
AddHandler tree.MouseDown, AddressOf tree_MouseDown
' process the mouse click on a node.
Private Sub tree_MouseDown(treeview As FlexibleTreeView, args As MouseActionArgs)
If args.NodeControl = checkBox Then
' change the check state manually
args.Node.CheckState = checkBox.GetNextCheckState(args.Node)
' and skip all further processing for this event.
args.Handled = True
End If
End Sub
Control check state changes manually#
If you want to control the node's check state manually (for example, to provide a non-standard check states sequence to the user), you need to create a custom node control class derived from NodeCheckBox and override the SetNextCheckState method.
Example
// Custom node control class where we manually replace the Checked check state with Unknown when node's check state has changed.
class MyNodeCheckBox : NodeCheckBox
{
// override the check state change logic and replace the Checked state with Unknown.
protected override void SetNextCheckState(Node node)
{
// Checked or Unknown -> Unchecked.
if (node.CheckState == eCheckState.Unknown)
{
node.CheckState = eCheckState.Unchecked;
}
// Unchecked -> Unknown.
else
{
node.CheckState = eCheckState.Unknown;
}
}
}
// create our node control.
MyNodeCheckBox nc = new MyNodeCheckBox();
nc.AttachTo(tree);
Node node = new Node();
// enable the three check states feature to be able to change to the Unknown state in our node control.
node.ThreeCheckState = true;
node.AttachTo(tree);
' Custom node control class where we manually replace the Checked check state with Unknown when node's check state has changed.
Class MyNodeCheckBox
Inherits NodeCheckBox
' override the check state change logic and replace the Checked state with Unknown.
Protected Overrides Sub SetNextCheckState(node As Node)
' Checked or Unknown -> Unchecked.
If node.CheckState = eCheckState.Unknown Then
node.CheckState = eCheckState.Unchecked
Else
' Unchecked -> Unknown.
node.CheckState = eCheckState.Unknown
End If
End Sub
End Class
' create our node control.
Dim nc As New MyNodeCheckBox()
nc.AttachTo(tree)
Dim node As New Node()
' enable the three check states feature to be able to change to the Unknown state in our node control.
node.ThreeCheckState = True
node.AttachTo(tree)
Override check icons#
By default, NodeCheckBox uses System or Office2007 theme check icons, but you can override them by using the Images treeview property.
Example
Additional API reference#
Properties#
- Editable - defines whether the node control can change the check state.