Completed
Last Updated: 03 Sep 2014 07:34 by ADMIN
ADMIN
Stefan
Created on: 28 Aug 2014 10:37
Category: TreeView
Type: Bug Report
1
FIX. RadTreeView - showing a MessageBox in the Edited event, causes the event to fire twice
Workaround:

 class MyTreeView : RadTreeView
        {
            protected override RadTreeViewElement CreateTreeViewElement()
            {
                return new MyTreeViewElement();
            }

            public override string ThemeClassName
            {
                get
                {
                    return typeof(RadTreeView).FullName;
                }
            }
        }

        class MyTreeViewElement : RadTreeViewElement
        {
            bool IsPerformingEndEdit = false;
            protected override bool EndEditCore(bool commitChanges)
            {
                if (!IsEditing || IsPerformingEndEdit)
                {
                    return false;
                }

                TreeNodeElement nodeElement = GetElement(this.SelectedNode);
                if (nodeElement == null)
                {
                    return false;
                }

                this.IsPerformingEndEdit = true;

                if (commitChanges && this.ActiveEditor.IsModified)
                {
                    SaveEditorValue(nodeElement, this.ActiveEditor.Value);
                }

                this.ActiveEditor.EndEdit();
                nodeElement.RemoveEditor(this.ActiveEditor);

                this.InvalidateMeasure();
                UpdateLayout();

                OnEdited(new TreeNodeEditedEventArgs(nodeElement, ActiveEditor, !commitChanges));

                typeof(RadTreeViewElement).GetField("activeEditor", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(this, null); 

                this.IsPerformingEndEdit = false;

                return false;
            }

            protected override Type ThemeEffectiveType
            {
                get
                {
                    return typeof(RadTreeViewElement);
                }
            }
        }
0 comments