This control makes users able to select predefined values from a
ComboBox instead of editing them inside a
The reader is expected to have basic Object Oriented concepts and awareness in C# coding.
Using the code
Just add the control to your form in design mode or in run time. There is a property in the control called "
combobox". It exposes the
ComboBox that will appear when editing in the tree. Just fill the data source of the
ComboBox. Do not forget to enable editing in the
The sample demo has all of this in brief.
All I did in the control was to inherit from the class "
TreeView" of the .NET Framework and override the
OnBeforeLabelEdit method of the class to show the
protected override void OnBeforeLabelEdit (NodeLabelEditEventArgs e)
current_tree_node = e.Node;
tcombo.Bounds = e.Node.Bounds; tcombo.Show();
Then I handled the event
SelectedIndexChanged of the
ComboBox to set the
TreeView label text with the selected text from the
private void tcombo_SelectedIndexChanged(object sender, EventArgs e)
current_tree_node.Text = tcombo.Text;
Version 1.0: 21/2/2005 (Posted).