我想要一个树节点的更多属性比价值和文本我想要5个属性 [英] I Want Some More Properties For A Tree Node Than Value And Text I Want Some 5 Properties

查看:57
本文介绍了我想要一个树节点的更多属性比价值和文本我想要5个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望树节点包含一些自定义属性来存储一些数据是否有可能请用vb.net代码解释windows窗体。



谢谢并关注

解决方案

您需要创建一个继承自TreeView的自定义树视图。

您还需要创建一个自定义树视图节点继承自TreeNode的类。



 公共  TreeViewTest 
继承 TreeView

公开 重载 属性节点() As List( Of TreeViewNode)

结束 Class

公共 < span class =code-keyword>类 TreeViewNode
继承 TreeNode
私有 m_iMyCustomNodeProperty 作为 整数

Public Property MyCustomNodeProperty As Integer
获取
返回 m_iMyCustomNodeProperty
结束 获取
设置(值作为 整数
m_iMyCustomNodeProperty = value
结束 设置
E nd 属性
结束





一旦你的自定义树视图类完成,你就可以这样使用它。

  Dim  oMyCustomTree  As   TreeViewTest 
oMyCustomTree.Nodes( 0 )。MyCustomNodeProperty = 1


是的。



 Node.Attributes.Add(SomeDate,11)

I want to have Tree Nodes containing some customized Properties to store some data into it is it possible please explain with vb.net code for windows form.

Thanks and regards

解决方案

You will need to create a custom treeview that inherits from TreeView.
You will also need to create a custom treeview node class that inherits from TreeNode.

Public Class TreeViewTest
    Inherits TreeView

    Public Overloads Property Nodes() As List(Of TreeViewNode)

End Class

Public Class TreeViewNode
    Inherits TreeNode
    Private m_iMyCustomNodeProperty As Integer

    Public Property MyCustomNodeProperty As Integer
        Get
            Return m_iMyCustomNodeProperty
        End Get
        Set(value As Integer)
            m_iMyCustomNodeProperty = value
        End Set
    End Property
End Class



Once your custom treeview class is complete you can use it in this manner.

Dim oMyCustomTree As New TreeViewTest
oMyCustomTree.Nodes(0).MyCustomNodeProperty = 1


Yea.

Node.Attributes.Add("SomeDate", "11")


这篇关于我想要一个树节点的更多属性比价值和文本我想要5个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆