|
NodeComboBox node control
Saturday, 12 September 2009
NodeComboBox allows you to show an item from a list and edit it using the combobox 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 the System.Int type. To supply combobox items use the DropDownItems property. Example: NodeComboBox cb = new NodeComboBox(); cb.AttachTo(tree); // define the combobox 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); Also, you can create an 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 combobox items mode. cb.InteractiveDropDownItems = true; cb.DataFieldName = "Id"; // Optional. Apply when you need to edit data in the combobox. cb.Editable = true; cb.AttachTo(tree); // handle the event to supply the combox items list. tree.NodeComboBoxGetItems += tree_NodeComboBoxGetItems;</p> <p>// 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 combobox`s dropdown items list. pArgs.Items = new string[] { "First", "Second", "Third" }; } To set the maximum items count in the drop–down portion of the combobox, use the MaxDropDownItems property.
|
|