By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Accessing/Setting Custom Properties in a Custom TreeNode

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.