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
458
How to disable UltraTree but leave scrolling enabled?
posted

We have two controls, a grid and a tree, that need to support being disabled to selection/editing but still be allowed to scroll.  We solved this issue for the grid with this:

 

mygrid.DisplayLayout.Override.AllowUpdate = (editMode == true) ? DefaultableBoolean.True : DefaultableBoolean.False;

 

A simliar construct for the UltraTree eludes us.  Right now we just disable the control to prevent editing and selection, but that prevents users from scrolling and viewing the data.  How can we enable the scrollbar but disable any selecting or editing in the tree?

  • 469350
    Offline posted

    Editing in the tree is disabled by default. So if your tree is editable, then you must be turning that on in code via the LabelEdit property, or other properties depending on the style of your tree.

    So that leaves selecting, activating, and expanding/collapsing of nodes.There's no single property for all of these, but it's pretty simple to disable these.You could do something like this:


            private void Form1_Load(object sender, EventArgs e)
            {
                for (int i = 0; i < 10; i++)
                {
                    UltraTreeNode parentNode = this.ultraTree1.Nodes.Add(null, "Parent" + i.ToString());
                    for (int j = 0; j < 10; j++)
                    {
                        parentNode.Nodes.Add(null, "Child " + j.ToString());
                    }
                }
                this.ultraTree1.ExpandAll();

                this.ultraTree1.Override.SelectionType = SelectType.None;               
            }

            private void ultraTree1_BeforeActivate(object sender, CancelableNodeEventArgs e)
            {
                e.Cancel = true;
            }

            private void ultraTree1_BeforeCollapse(object sender, CancelableNodeEventArgs e)
            {
                e.Cancel = true;
            }

     

    Another option would be to disable each node. You could do this when you add the node, or loop through the nodes recursively after they are added. Or, if your tree is bound, you could use the InitializeDataNode event to disable each node.