NodeComboBox
NodeComboBox allows you to show one item from a list and edit the selected item using a combo box control. This node control tracks the selected item's index, so you need to bind it to any numeric type that can be converted to System.Int
type.
To provide the combo box items, use the DropDownItems property, as shown below.
// Custom node class to hold the selected item index.
class NodeEx : Node
{
public int Position { get; set; }
}
NodeComboBox cb = new NodeComboBox();
cb.AttachTo(tree);
// define the combo box items list.
string[] objects = new[] { "First", "Second", "Third" };
cb.DropDownItems = new List<object>(objects);
// bind the node control to the node's member where the selected index will be stored.
cb.DataFieldName = "Position";
NodeEx node = new NodeEx();
// second position (zero based) by default is selected.
node.Position = 1;
node.AttachTo(tree);
' Custom node class to hold the selected item index.
Class NodeEx
Inherits Node
Public Position As Integer
End Class
Dim cb As New NodeComboBox()
cb.AttachTo(tree)
' define the combo box items list.
Dim objects As String() = New String() {"First", "Second", "Third"}
cb.DropDownItems = New List(Of Object)(objects)
' bind the node control to the node's member where the selected index will be stored.
cb.DataFieldName = "Position"
Dim node As New NodeEx()
' second position (zero based) by default is selected.
node.Position = 1
node.AttachTo(tree)
Also, you can fill the combo box items list dynamically by enabling the InteractiveDropDownItems property and subscribing to the NodeComboBoxGetItems treeview event, as shown below.
// Custom node class to hold the selected item index.
class NodeEx : Node
{
public int Position { get; set; }
}
NodeComboBox cb = new NodeComboBox();
// enable the dynamic combo box items mode.
cb.InteractiveDropDownItems = true;
cb.DataFieldName = "Position";
// Optional. Apply when you need to edit data in the combo box.
cb.Editable = true;
cb.AttachTo(tree);
// handle the event to supply the combo box items list.
tree.NodeComboBoxGetItems += tree_NodeComboBoxGetItems;
// add node.
NodeEx node = new NodeEx();
// default selected item's index.
node.Position = 1;
node.AttachTo(tree);
private void tree_NodeComboBoxGetItems(FlexibleTreeView treeview, NodeComboBoxGetItemsEventArgs args)
{
// supply the combo box's dropdown items list.
args.Items = new string[] { "First", "Second", "Third" };
}
' Custom node class to hold the selected item index.
Class NodeEx
Inherits Node
Public Position As Integer
End Class
Dim cb As New NodeComboBox()
' enable the dynamic combo box items mode.
cb.InteractiveDropDownItems = True
cb.DataFieldName = "Position"
' Optional. Apply when you need to edit data in the combo box.
cb.Editable = True
cb.AttachTo(tree)
' handle the event to supply the combo box items list.
AddHandler tree.NodeComboBoxGetItems, AddressOf tree_NodeComboBoxGetItems
' add node.
Dim node As New NodeEx()
' default selected item's index.
node.Position = 1
node.AttachTo(tree)
Private Sub tree_NodeComboBoxGetItems(treeview As FlexibleTreeView, args As NodeComboBoxGetItemsEventArgs)
' supply the combo box's dropdown items list.
args.Items = New String() {"First", "Second", "Third"}
End Sub
Tip
To limit the items count shown in the combo box drop-down portion, use the MaxDropDownItems node control property.