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
40
UltraTreeNode - Enter edit mode, set focus, selectall
posted

Tried searching for this, forum search doesn't work at all for me -- so apologies if this is redundant. 

I've got a project where the UltraTree is displaying file system folders -- and they can add a folder. When they add a folder I'd like it to enter edit mode, set focus to the editor (which apparently defaults to null all the time?), and select all text within that editor.

It appears to be designed to function this way, when I attempted to set the Override.Editor to a EditorWithText -- it just didn't even go into edit mode anymore. So I'm clearly missing some key information there and I was not able to find any samples or documentation related to this. If there are, by all means just point me at them - at this point I've spent way more time on this than I should have since everything on it works great except that pesky little set focus and select editor text part, lol.

Thanks

  • 0
    Offline posted

    To locate relevant examples or written material. I've spent much more time than I should have on this, and everything works perfectly except for the set focus and choose editor text section, so please direct me there if you find any. 

    free games

  • 29105
    Offline posted

    Hello Kelly, 

    I attached a sample. Normally you can just set the tree.Override.LabelEdit to DefaultableBoolean.True  to allow nodes to be editable and call tree.PerformaAction(UltraTreeAction.EnterEditMode, false, false) which will automatically select all text.

    However if you are using the View.OutlookExpress style to render cells to embed EditorWithText then you need to hook the editor's AfterEnterEditMode event to perform a SelectAll on the editor. 

    eg.

    private void Editor_AfterEnterEditMode(object sender, EventArgs e)
            {
                EditorWithText editor = (EditorWithText)sender;
                editor.SelectAll();
            }
    5481.WindowsFormsApp4.zip

    Let me know if you have any questions.

  • 40
    Offline posted

    Going to leave this here in case someone else runs into this -- but the issue I was having was being caused by a selection event causing the control to lose focus. So I just took that out and have it instead select the node on exit of edit mode and problem is solved.