Results 1 to 7 of 7

Thread: [Resolved] TreeView AfterLabelEdit problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Location
    Sweden
    Posts
    21

    Resolved [Resolved] TreeView AfterLabelEdit problem

    I need to know when a node has been renamed and then save the new name. If I use AfterLabelEdit event it has still got the old name of the node. Has anyone got a solution for this?
    VB Code:
    1. Private Sub tvTreeView_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles tvTreeView.AfterLabelEdit
    2.         MessageBox.Show(e.Label)
    3.     End Sub
    Last edited by jaaan; Dec 6th, 2005 at 12:38 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: TreeView AfterLabelEdit problem

    I just tested it and e.Node.Text contains the old value and e.Label contains the new value. If that doesn't happen in your app then that's just weird.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Location
    Sweden
    Posts
    21

    Re: TreeView AfterLabelEdit problem

    You are right! That is the way it works.
    What I am trying to do is this:
    VB Code:
    1. Private Sub tvTreeView_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles tvTreeView.AfterLabelEdit
    2.         Call WriteConfigFile()
    3.     End Sub
    Where the WriteConfigFile sub is saving the tree to a file, but from that sub I can only reach the old value.

  4. #4
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: TreeView AfterLabelEdit problem

    You may want to pass the old an new values to the sub that way you can make the proper changes when writing the file. When you catch that event, the new label hasn't been applied yet and thus the reason you cannot get the file to write the proper values.

    Modify the WriteConfigFile() sub to check for that old value and substitute the new value is my suggestion.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Location
    Sweden
    Posts
    21

    Re: TreeView AfterLabelEdit problem

    Thanks tacoman667, that is a good suggestion but this is only one of many times I use the WriteConfigFile() sub and in the others I don´t have this problem. So I would rather not modify the WriteConfigFile() sub. Any other suggestion?

  6. #6
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: TreeView AfterLabelEdit problem

    Do an overloads sub for WriteConfigFile() that way you can use that one to pass those arguments into. As far as I know there is NO way to get past the fact that the node.text is not changed when that event is fired off. That event is for if you want to validate the information before it applies, that way you can cancel the edit.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Location
    Sweden
    Posts
    21

    Re: TreeView AfterLabelEdit problem

    OK, thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width