469,330 Members | 1,269 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Accessing/Setting Custom Properties in a Custom TreeNode

I've figured out how to create a custom TreeNode with custom properties
and I can view those properties at runtime, but I'm not sure how to
change them after I've added the custom node to the tree.

For example:

Public Class CustomTreeNode

Inherits TreeNode

Dim _CustomProperty as String

Public Property CustomProperty() As String
Get
Return Me._CustomProperty
End Get
Set(ByVal value As String)
_CustomProperty = value
End Set
End Property

End Class

Add the node to the tree:

....
Dim myCustomTreeNode as New CustomTreeNode
myCustomTreeNode.CustomProperty = "Google is great."
TreeView1.Nodes.Add(myCustomTreeNode)
....

Read the property in the AfterSelect event:

....
Dim myCustomTreeNode as New CustomTreeNode
myCustomTreeNode = CType(e.Node, CustomTreeNode)
MsgBox(myCustomTreeNode.CustomProperty)
....

Now, how to I change the value of CustomProperty?

....
Dim myCustomTreeNode as New CustomTreeNode
myCustomTreeNode.CustomProperty = "Google is really great."
TreeView1.SelectedNode = myCustomTreeNode
....

This doesn't appear to work. Any suggestions?

Bishop

Nov 21 '05 #1
0 2420

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jason Butera | last post: by
6 posts views Thread by Angel | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.