当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 继承创建自定义的TreeView

继承创建自定义的TreeView

点击次数:24 次 发布日期:2008-11-26 23:57:33 作者:源代码网
源代码网推荐 CustomTreeViewForm类,好东西大家分享,好好研究一下哦!
源代码网推荐 Public Class CustomTreeViewForm
源代码网推荐     Inherits System.Windows.Forms.Form
源代码网推荐
源代码网推荐 #Region " Windows Form Designer generated code "
源代码网推荐
源代码网推荐     Public Sub New()
源代码网推荐         MyBase.New()
源代码网推荐
源代码网推荐         "This call is required by the Windows Form Designer.
源代码网推荐         InitializeComponent()
源代码网推荐
源代码网推荐         "Add any initialization after the InitializeComponent() call
源代码网推荐         InitializeForm()
源代码网推荐     End Sub
源代码网推荐
源代码网推荐     "Form overrides dispose to clean up the component list.
源代码网推荐     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
源代码网推荐         If disposing Then
源代码网推荐             If Not (components Is Nothing) Then
源代码网推荐                 components.Dispose()
源代码网推荐             End If
源代码网推荐         End If
源代码网推荐         MyBase.Dispose(disposing)
源代码网推荐     End Sub
源代码网推荐
源代码网推荐     "Required by the Windows Form Designer
源代码网推荐     Private components As System.ComponentModel.IContainer
源代码网推荐
源代码网推荐     "NOTE: The following procedure is required by the Windows Form Designer
源代码网推荐     "It can be modified using the Windows Form Designer.  
源代码网推荐     "Do not modify it using the code editor.
源代码网推荐     Friend WithEvents tvwCategories As System.Windows.Forms.TreeView
源代码网推荐     Friend WithEvents txtSelectedID As System.Windows.Forms.TextBox
源代码网推荐     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
源代码网推荐         Me.tvwCategories = New System.Windows.Forms.TreeView()
源代码网推荐         Me.txtSelectedID = New System.Windows.Forms.TextBox()
源代码网推荐         Me.SuspendLayout()
源代码网推荐         "
源代码网推荐         "tvwCategories
源代码网推荐         "
源代码网推荐         Me.tvwCategories.ImageIndex = -1
源代码网推荐         Me.tvwCategories.Location = New System.Drawing.Point(7, 2)
源代码网推荐         Me.tvwCategories.Name = "tvwCategories"
源代码网推荐         Me.tvwCategories.SelectedImageIndex = -1
源代码网推荐         Me.tvwCategories.Size = New System.Drawing.Size(277, 240)
源代码网推荐         Me.tvwCategories.TabIndex = 0
源代码网推荐         "
源代码网推荐         "txtSelectedID
源代码网推荐         "
源代码网推荐         Me.txtSelectedID.Location = New System.Drawing.Point(6, 246)
源代码网推荐         Me.txtSelectedID.Name = "txtSelectedID"
源代码网推荐         Me.txtSelectedID.Size = New System.Drawing.Size(278, 20)
源代码网推荐         Me.txtSelectedID.TabIndex = 1
源代码网推荐         Me.txtSelectedID.Text = "txtSelectedID"
源代码网推荐         "
源代码网推荐         "CustomTreeViewForm
源代码网推荐         "
源代码网推荐         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
源代码网推荐         Me.ClientSize = New System.Drawing.Size(292, 273)
源代码网推荐         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtSelectedID, Me.tvwCategories})
源代码网推荐         Me.Name = "CustomTreeViewForm"
源代码网推荐         Me.Text = "Custom TreeView"
源代码网推荐         Me.ResumeLayout(False)
源代码网推荐
源代码网推荐     End Sub
源代码网推荐
源代码网推荐 #End Region
源代码网推荐     Private Sub InitializeForm()
源代码网推荐         Dim objCategories As New Categories()
源代码网推荐         Dim i As Integer
源代码网推荐         Dim x As Integer
源代码网推荐         For i = 1 To 5
源代码网推荐             With objCategories.Add(New Category())
源代码网推荐                 .CategoryID = "CAT" & i
源代码网推荐                 .DisplayName = "Category " & i
源代码网推荐                 For x = 1 To 3
源代码网推荐                     With .AccountTypes.Add(New AccountType())
源代码网推荐                         .AccountTypeID = "A" & x
源代码网推荐                         .DisplayName = "AccountType " & x
源代码网推荐                     End With
源代码网推荐                     With .PartTypes.Add(New PartType())
源代码网推荐                         .PartTypeID = "P" & x
源代码网推荐                         .DisplayName = "PartType " & x
源代码网推荐                     End With
源代码网推荐                 Next x
源代码网推荐             End With
源代码网推荐         Next i
源代码网推荐         With Me.tvwCategories
源代码网推荐             Dim objCategory As Category
源代码网推荐             Dim objAccountType As AccountType
源代码网推荐             Dim objPartType As PartType
源代码网推荐             Dim objCategoryTreeNode As CategoryTreeNode
源代码网推荐             For Each objCategory In objCategories
源代码网推荐                 objCategoryTreeNode = New CategoryTreeNode(objCategory)
源代码网推荐                 .Nodes.Add(objCategoryTreeNode)
源代码网推荐                 With objCategoryTreeNode
源代码网推荐                     For Each objAccountType In objCategory.AccountTypes
源代码网推荐                         .Nodes.Add(New AccountTypeTreeNode(objAccountType))
源代码网推荐                     Next
源代码网推荐                     For Each objPartType In objCategory.PartTypes
源代码网推荐                         .Nodes.Add(New PartTypeTreeNode(objPartType))
源代码网推荐                     Next
源代码网推荐                 End With
源代码网推荐             Next
源代码网推荐         End With
源代码网推荐     End Sub
源代码网推荐
源代码网推荐     Private Sub tvwCategories_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwCategories.AfterSelect
源代码网推荐         Dim objNode As TreeNode
源代码网推荐         objNode = tvwCategories.SelectedNode
源代码网推荐         Select Case objNode.GetType.ToString
源代码网推荐             Case "CustomTreeView.CategoryTreeNode"
源代码网推荐                 Dim objCategoryTreeNode As CategoryTreeNode
源代码网推荐                 objCategoryTreeNode = CType(objNode, CategoryTreeNode)
源代码网推荐                 txtSelectedID.Text = objCategoryTreeNode.Category.CategoryID.ToString
源代码网推荐             Case "CustomTreeView.AccountTypeTreeNode"
源代码网推荐                 Dim objAccountTypeTreeNode As AccountTypeTreeNode
源代码网推荐                 objAccountTypeTreeNode = CType(objNode, AccountTypeTreeNode)
源代码网推荐                 txtSelectedID.Text = objAccountTypeTreeNode.AccountType.AccountTypeID.ToString
源代码网推荐             Case "CustomTreeView.PartTypeTreeNode"
源代码网推荐                 Dim objPartTypeTreeNode As PartTypeTreeNode
源代码网推荐                 objPartTypeTreeNode = CType(objNode, PartTypeTreeNode)
源代码网推荐                 txtSelectedID.Text = objPartTypeTreeNode.PartType.PartTypeID.ToString
源代码网推荐         End Select
源代码网推荐     End Sub
源代码网推荐 End Class
源代码网推荐 Public Class AccountType
源代码网推荐     Public AccountTypeID As String
源代码网推荐     Public DisplayName As String
源代码网推荐 End Class
源代码网推荐 Public Class PartType
源代码网推荐     Public PartTypeID As String
源代码网推荐     Public DisplayName As String
源代码网推荐 End Class
源代码网推荐 Public Class Category
源代码网推荐     Public CategoryID As String
源代码网推荐     Public DisplayName As String
源代码网推荐     Public AccountTypes As New AccountTypes()
源代码网推荐     Public PartTypes As New PartTypes()
源代码网推荐 End Class
源代码网推荐 Public Class Categories
源代码网推荐     Inherits CollectionBase
源代码网推荐     Public Function Add(ByVal value As Category) As Category
源代码网推荐         Me.InnerList.Add(value)
源代码网推荐         Add = value
源代码网推荐     End Function
源代码网推荐 End Class
源代码网推荐 Public Class AccountTypes
源代码网推荐     Inherits CollectionBase
源代码网推荐     Public Function Add(ByVal value As AccountType) As AccountType
源代码网推荐         Me.InnerList.Add(value)
源代码网推荐         Add = value
源代码网推荐     End Function
源代码网推荐 End Class
源代码网推荐 Public Class PartTypes
源代码网推荐     Inherits CollectionBase
源代码网推荐     Public Function Add(ByVal value As PartType) As PartType
源代码网推荐         Me.InnerList.Add(value)
源代码网推荐         Add = value
源代码网推荐     End Function
源代码网推荐 End Class
源代码网推荐 Public Class AccountTypeTreeNode
源代码网推荐     Inherits TreeNode
源代码网推荐     Public AccountType As AccountType
源代码网推荐     Sub New(ByVal Value As AccountType)
源代码网推荐         MyBase.New()
源代码网推荐         AccountType = Value
源代码网推荐         Me.Text = AccountType.DisplayName
源代码网推荐     End Sub
源代码网推荐 End Class
源代码网推荐 Public Class PartTypeTreeNode
源代码网推荐     Inherits TreeNode
源代码网推荐     Public PartType As PartType
源代码网推荐     Sub New(ByVal Value As PartType)
源代码网推荐         MyBase.New()
源代码网推荐         PartType = Value
源代码网推荐         Me.Text = PartType.DisplayName
源代码网推荐     End Sub
源代码网推荐 End Class
源代码网推荐 Public Class CategoryTreeNode
源代码网推荐     Inherits TreeNode
源代码网推荐     Public Category As Category
源代码网推荐     Sub New(ByVal Value As Category)
源代码网推荐         MyBase.New()
源代码网推荐         Category = Value
源代码网推荐         Me.Text = Category.DisplayName
源代码网推荐     End Sub
源代码网推荐 End Class
源代码网推荐
源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华