|
-
Dec 5th, 2005, 11:12 AM
#1
Thread Starter
Junior Member
[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:
Private Sub tvTreeView_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles tvTreeView.AfterLabelEdit
MessageBox.Show(e.Label)
End Sub
Last edited by jaaan; Dec 6th, 2005 at 12:38 PM.
-
Dec 5th, 2005, 06:36 PM
#2
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.
-
Dec 6th, 2005, 11:50 AM
#3
Thread Starter
Junior Member
Re: TreeView AfterLabelEdit problem
You are right! That is the way it works.
What I am trying to do is this:
VB Code:
Private Sub tvTreeView_AfterLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles tvTreeView.AfterLabelEdit
Call WriteConfigFile()
End Sub
Where the WriteConfigFile sub is saving the tree to a file, but from that sub I can only reach the old value.
-
Dec 6th, 2005, 11:57 AM
#4
Hyperactive Member
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.
-
Dec 6th, 2005, 12:05 PM
#5
Thread Starter
Junior Member
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?
-
Dec 6th, 2005, 12:13 PM
#6
Hyperactive Member
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.
-
Dec 6th, 2005, 12:37 PM
#7
Thread Starter
Junior Member
Re: TreeView AfterLabelEdit problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|