Completed
Last Updated: 19 Jun 2017 12:11 by ADMIN
Piotr
Created on: 08 Mar 2017 09:36
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView - exception when pressing arrow down or up when renaming node with scrollbar
Pressing arrow down or up when renaming item on a list with scrollbar throws null pointer exception. Example solution in attachement. 

Steps to reproduce with attached solution: 
Scroll down to last element (A99) 
Press F2 (rename) and rename to "0"
Press arrow up or down on a keyboard (without pressing enter after rename). -> NullReferenceException is thrown.
Attached Files:
3 comments
ADMIN
Peter
Posted on: 08 Mar 2017 12:28
We will do our best to provide a fix for R2 2017 release.
Piotr
Posted on: 08 Mar 2017 11:58
Thanks for a quick response :)
ADMIN
Peter
Posted on: 08 Mar 2017 11:04
Workaround:
     Handle EditorRequired event
     radTreeView1.EditorRequired += RadTreeView1_EditorRequired;

private void RadTreeView1_EditorRequired(object sender, TreeNodeEditorRequiredEventArgs e)
        {
            e.Editor = new CustomTreeViewTextBoxEditor();
        }
    }

    class CustomTreeViewTextBoxEditor : TreeViewTextBoxEditor
    {
        protected override void OnKeyDown(KeyEventArgs e)
        {
            TreeNodeElement nodeElement = this.OwnerElement as TreeNodeElement;
            if (nodeElement != null && nodeElement.TreeViewElement != null)
            {
                switch (e.KeyCode)
                {   
                    case Keys.Up:
                        if (!this.Multiline || (selectionLength == 0 && isAtFirstLine))
                        {
                            RadTreeViewElement treeView = nodeElement.TreeViewElement;
                            nodeElement.TreeViewElement.EndEdit();
                            treeView.Update(RadTreeViewElement.UpdateActions.Reset);
                        }
                        break;

                    case Keys.Down:
                        if (!this.Multiline || (selectionLength == 0 && isAtLastLine))
                        {
                            RadTreeViewElement treeView = nodeElement.TreeViewElement;
                            nodeElement.TreeViewElement.EndEdit();
                            treeView.Update(RadTreeViewElement.UpdateActions.Reset);
                        }
                        break;
                }
            }
            base.OnKeyDown(e);
        }
    }