Flexible TreeView 5.1.9 Help
NodeComboBox node control

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.

Example:

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);
Dim cb As New NodeComboBox()
cb.AttachTo(tree)
' define the combo box items list.
Dim objects As String() = New () {"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.

Example:

// Custom node class to hold the selected item index.
class NodeEx : Node
{
  public int Id;
}
 
NodeComboBox cb = new NodeComboBox();
// enable the dynamic combo box items mode.
cb.InteractiveDropDownItems = true;
cb.DataFieldName = "Id";
// 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.Id = 1;
node.AttachTo(tree);
 
private void tree_NodeComboBoxGetItems(FlexibleTreeView pTreeview, NodeComboBoxGetItemsEventArgs pArgs)
{
  // supply the combo box's dropdown items list.
  pArgs.Items = new string[] { "First", "Second", "Third" };
}
' Custom node class to hold the selected item index.
Class NodeEx
    Inherits Node
    Public Id As Integer
End Class

Dim cb As New NodeComboBox()
' enable the dynamic combo box items mode.
cb.InteractiveDropDownItems = True
cb.DataFieldName = "Id"
' 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.
Dim node As New NodeEx()
' default selected item's index.
node.Id = 1
node.AttachTo(tree)

Private Sub tree_NodeComboBoxGetItems(pTreeview As FlexibleTreeView, pArgs As NodeComboBoxGetItemsEventArgs)
    ' supply the combo box's dropdown items list.
    pArgs.Items = New String() {"First", "Second", "Third"}
End Sub

To limit the items count shown in the combo box drop-down portion, use the MaxDropDownItems property.

 

 


Copyright © 2006-2016 ARMSoft

www.FlexibleTreeView.com