TreeView Edited event NewValue and OldValue

8 posts, 0 answers
  1. Lauren Nickerson
    Lauren Nickerson avatar
    52 posts
    Member since:
    Jul 2009

    Posted 23 Dec 2009 Link to this post

    Hi, so I'm in this event I need the old value to do some evaluation, but instead, I get the NewValue on both objects:

    private void treeViewExperimentExplorer_Edited(object sender, RadTreeViewItemEditedEventArgs e) 
        string newName = e.NewValue.ToString(); 
        string oldName = e.OldValue.ToString(); 

    In there both newName and oldName have the new value. How can I get the previous value in there?

    Thanks!
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 28 Dec 2009 Link to this post

    Hi Lauren Nickerson,

    Unfortunately when the TreeView uses an ItemEditTemplate (i.e. it is bound) it will not populate these properties. They contain just the data item that the TreeView is bound to.

    We are looking to enable these properties for the Q1 release of the controls when the TreeView is bound.

    In the meantime I can suggest storing the value that you need in a field when editing starts and then refering to it if you need to when editing ends.

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Lauren Nickerson
    Lauren Nickerson avatar
    52 posts
    Member since:
    Jul 2009

    Posted 28 Dec 2009 Link to this post

    That was plan B. Thanks!
  5. Menny
    Menny avatar
    3 posts
    Member since:
    Jun 2009

    Posted 29 Jan 2012 Link to this post

    its 2012 now and this still happens
  6. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 01 Feb 2012 Link to this post

    Hello Menny,

    The previously mentioned behavior is by design. Our suggestion is to use the PreviewEdited and Edited events to distinguish between the new and old values. Please take a look at the attached project for further reference.

    Greetings,
    Kiril Stanoev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Menny
    Menny avatar
    3 posts
    Member since:
    Jun 2009

    Posted 05 Feb 2012 Link to this post

    yeh, figured it out
  8. Albert
    Albert avatar
    27 posts
    Member since:
    Sep 2012

    Posted 06 Feb 2013 Link to this post

    Hello Kiril,

    I ran the project in 269235.zip , but it appears that this.oldTitle is always equal to the newly edited value. I am unable to find the value before editing (ie. the oldValue). What am I missing here?

    Kind Regards,
    Albert
  9. Albert
    Albert avatar
    27 posts
    Member since:
    Sep 2012

    Posted 06 Feb 2013 Link to this post

    Okay, I figured it out.

    I handled the EditStarted event to store the value before the edit occurs:

            private void treeView1_EditStarted(object sender, Telerik.Windows.Controls.RadTreeViewItemEditedEventArgs e)
            {
                this.titleBeforeEdit = (e.OldValue as DataItem).Title;            
            }

    Kind Regards,
    Albert
Back to Top
UI for WPF is Visual Studio 2017 Ready