Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
TreeNode with CustomControl or with UltraComboEditor
posted

I have a UltraTree with Nodes, where i want a UltraComboEditor beside. My Node now has a Checkbox, a Image and a Text. 

Beside the Text should be a ComboEditor.

You can see how the tree should look like in the next picture. 


UltraTreeNode node = new UltraTreeNode();
node.Override.NodeStyle = NodeStyle.CheckBox;
node.LeftImages.Add(element.Image);
node.Text = element.Text;


When i put a EditorComponent on the Node, then i loose the text but get the UltraComboEditor instead.
node.Override.EditorComponent = new UltraComboEditor();



How do i get a node how it looks like in Picture 1?
I tried to write a MyCustomControl with a UltraLabel and a UltraComboEditor as a UserControl, but i can't
set it as EditorComponent. Need some help how to write the CustomControl please.

node.Override.EditorComponent = new MyCustomControl();
Parents
  • 467910
    Verified Answer
    Offline posted

    Hi, 

    There are a few different ways you might go about achieving this. But you can't really do it with a single ViewStyle.Standard node.

    One hurdle is that a ViewStyle.Standard node doesn't have any way to store a third piece of information. The UltraTreeNode has a CheckState property to store the state of the built-in checkbox and it has a Text property to store the text. But there's no third property to store the value of a ComboEditor. Attaching an UltraComboEditor to the node edits the node's Text. 

    So the simplest way I can see to get around this would be to make your child nodes show in ViewStyle.Grid. That way you could have a column for the checkbox, one for the image, one for the text and one for the combo. How you do that depends on the structure of your tree, but from the screenshots here, it looks like you have a pretty simple structure with only two levels. So if that's the case and your second level is always going to be child nodes, you could create a ColumnSet and apply it to the tree's NodeLevelOverrides for the second level. 

    I attached a small sample project here to demonstrate the basics.

     WindowsFormsApplication19.zip

Reply Children