www.pudn.com > ListViewTreeView.rar > Form1.frm


VERSION 5.00 
Begin VB.Form Form1  
   Caption         =   "海阔天空收集整理 www.play78.com" 
   ClientHeight    =   5055 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   4500 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5055 
   ScaleWidth      =   4500 
   StartUpPosition =   3  '窗口缺省 
   Begin VB.TextBox Text2  
      Height          =   285 
      Left            =   1440 
      TabIndex        =   3 
      Top             =   4770 
      Width           =   2655 
   End 
   Begin VB.TextBox Text1  
      Height          =   285 
      Left            =   1440 
      TabIndex        =   1 
      Top             =   4410 
      Width           =   2655 
   End 
   Begin VB.ListBox List1  
      Appearance      =   0  'Flat 
      BackColor       =   &H00FFFFC0& 
      CausesValidation=   0   'False 
      Height          =   4350 
      IntegralHeight  =   0   'False 
      Left            =   30 
      TabIndex        =   0 
      Top             =   0 
      Width           =   4455 
   End 
   Begin VB.Label Label2  
      Caption         =   "当前选择" 
      Height          =   255 
      Left            =   0 
      TabIndex        =   4 
      Top             =   4770 
      Width           =   1575 
   End 
   Begin VB.Label Label1  
      Caption         =   "快速查询" 
      Height          =   255 
      Left            =   0 
      TabIndex        =   2 
      Top             =   4410 
      Width           =   1575 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
 
' ********************************************************************** 
'  描  述:在listbox中实现treeview数效果 
'  Play78.com : 网站导航,源码之家,绝对开源 
'  海阔天空收集整理 
'  网址:http://www.play78.com/ 
'  QQ:13355575 
'  e-mail:hglai@eyou.com 
'  编写日期:2005年07月28日 
' ********************************************************************** 
 
Option Explicit 
 
Private WithEvents trv As cls_TreeView 
Attribute trv.VB_VarHelpID = -1 
 
' 
' 
' 
 
Private Sub Form_Load() 
 
    Set trv = New cls_TreeView 
    trv.Init List1 
 
    Dim i As Long 
    For i = 9 To 0 Step -1 
 
        trv.AddItem "", i & "项目名称", "KEY" & i, "VALUE" & i 
 
        Dim j As Long 
        For j = 0 To 5 
 
            trv.AddItem "KEY" & i, "KEY" & i & "-" & j & " 项目名称", "KEY" & i & "-" & j, "VALUE" & i & j 
 
            Dim k As Long 
            For k = 4 To 1 Step -1 
                trv.AddItem "KEY" & i & "-" & j, "KEY" & i & "-" & j & "-" & k & " 项目名称", "KEY" & i & "-" & j & "-" & k, "VALUE" & i & j & k 
            Next 
 
        Next 
 
    Next 
 
    trv.Refresh 
 
End Sub 
 
' 
' 
' 
 
Private Sub Text1_Change() 
    trv.HighLight trv.FindFirstKey(Text1.Text) 
End Sub 
 
' 
' 
' 
 
Private Sub trv_SelectionChange(Key As String) 
    Text2.Text = trv.GetValue(Key) 
End Sub