⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeview.frm

📁 适合乡镇供电所使用电费处理系统v3 软件
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmTreeview 
   AutoRedraw      =   -1  'True
   Caption         =   "TreeView 和 ListView"
   ClientHeight    =   5655
   ClientLeft      =   735
   ClientTop       =   2640
   ClientWidth     =   9660
   Icon            =   "TREEVIEW.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   5655
   ScaleWidth      =   9660
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   4170
      Left            =   5115
      TabIndex        =   6
      Top             =   735
      Width           =   4320
      _ExtentX        =   7620
      _ExtentY        =   7355
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.ComboBox cmbView 
      Height          =   315
      Left            =   6960
      TabIndex        =   4
      Text            =   "Combo1"
      Top             =   0
      Width           =   2415
   End
   Begin VB.CommandButton cmdLoad 
      Caption         =   "加载"
      Height          =   270
      Left            =   2190
      TabIndex        =   1
      Top             =   4935
      Visible         =   0   'False
      Width           =   1050
   End
   Begin MSComctlLib.StatusBar sbrDB 
      Align           =   2  'Align Bottom
      Height          =   255
      Left            =   0
      TabIndex        =   5
      Top             =   5400
      Width           =   9660
      _ExtentX        =   17039
      _ExtentY        =   450
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   1
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ProgressBar prgLoad 
      Height          =   210
      Left            =   255
      TabIndex        =   3
      Top             =   375
      Visible         =   0   'False
      Width           =   9090
      _ExtentX        =   16034
      _ExtentY        =   370
      _Version        =   393216
      Appearance      =   1
   End
   Begin MSComctlLib.ListView lvwDB 
      Height          =   4215
      Left            =   3465
      TabIndex        =   2
      Top             =   615
      Width           =   1290
      _ExtentX        =   2275
      _ExtentY        =   7435
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      _Version        =   393217
      Icons           =   "imlIcons"
      SmallIcons      =   "imlSmallIcons"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Appearance      =   1
      NumItems        =   0
   End
   Begin MSComDlg.CommonDialog dlgDialog 
      Left            =   1605
      Top             =   4830
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      FilterIndex     =   474
      FontSize        =   8.01821e-38
   End
   Begin MSComctlLib.TreeView tvwDB 
      Height          =   4215
      Left            =   255
      TabIndex        =   0
      Top             =   615
      Width           =   3120
      _ExtentX        =   5503
      _ExtentY        =   7435
      _Version        =   393217
      LineStyle       =   1
      Style           =   7
      ImageList       =   "imlSmallIcons"
      Appearance      =   1
   End
   Begin MSComctlLib.ImageList imlIcons 
      Left            =   645
      Top             =   4800
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   32
      ImageHeight     =   32
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   1
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":0442
            Key             =   "book"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.ImageList imlSmallIcons 
      Left            =   45
      Top             =   4815
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   13
      ImageHeight     =   13
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   6
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":075C
            Key             =   "closed"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":08CE
            Key             =   "cylinder"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":0A40
            Key             =   "leaf"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":0BB2
            Key             =   "open"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":0D24
            Key             =   "smlBook"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "TREEVIEW.frx":0FD6
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Menu mnuFile 
      Caption         =   "文件(&F)"
      Begin VB.Menu mnuLoad 
         Caption         =   "加载(&L)"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "退出(&X)"
      End
   End
End
Attribute VB_Name = "frmTreeview"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private mNode As node ' 模块级节点变量。
Private mItem As ListItem ' 模块级列表项变量。
Private EventFlag As Integer ' 标记所发生的事件。
Private mCurrentIndex As Integer ' 设置标志保证这个节点没有被单击。
Private mStatusBarStyle As Integer ' 切换状态栏样式。
Private cn As ADODB.Connection ' 我们仅仅使用一个活动的连接。
Attribute cn.VB_VarHelpID = -1

Const PUBLISHER = 1 ' 对于 EventFlag, 标记发行商 colmunheader 对象。
Const TITLE = 2 ' EventFlag, 在 ListView 中标记标题
Private Sub cmdLoad_Click()
    Dim intCounter As Integer ' Counter to set Progressbar.Value
    Dim intIndex ' Variable for index of current node.
    Dim TempName As String
    ' 设置 ADODB 连接对象的连接字符串并且打开它。
    
    ' 创建 ADODB 记录集对象变量。
    Dim rsPublishers As New ADODB.Recordset
    ' 打开记录集。
    With rsPublishers
        .Open "SELECT ID, [用户名称] FROM 用户电费", cn, adOpenStatic, adLockOptimistic
        ' 移动到记录尾部获得记录号,然后返回。
        .MoveLast
        .MoveFirst
    End With
    ' 将进程栏设置为最大,并且使它可视。
    With prgLoad
        .Max = rsPublishers.RecordCount
        .Visible = True
    End With
    
    ' 当此记录不是最后一条记录时,添加 ListItem 对象。
    ' 为 ListItem 对象的文本使用 Name 字段。
    Do While Not rsPublishers.eof
        intCounter = intCounter + 1
        prgLoad.Value = intCounter ' 更新进程栏。
        
        ' 添加节点到 TreeView, 并且设置它的属性。 & " ID"
        If tvwDB.SelectedItem <> rsPublishers!用户名称 Then
           Set mNode = tvwDB.Nodes.Add(1, tvwChild, rsPublishers!ID & " ID", CStr(rsPublishers![用户名称]), "closed")
        End If
        'Set mNode = tvwDB.Nodes.Add(1, tvwChild, CStr(rsPublishers![用户名称]), "closed")
        
        mNode.Tag = "Publisher" ' 标识此表。
        
        ' 设置变量 intIndex 到新创建的节点的 Index 属性。
        ' 使用此变量添加子节点对象到现在的节点。
        intIndex = mNode.Index
        
        rsPublishers.MoveNext   ' 移动到下一个出版商记录。
    Loop
    ' 隐藏进程栏
    prgLoad.Visible = False
    ' 将状态栏样式设置为标准。
    sbrDB.Style = sbrNormal
    ' 对出版商节点进行排序。
    tvwDB.Nodes(1).Sorted = True
    ' 扩展顶节点。
    tvwDB.Nodes(1).Expanded = True
    
End Sub

Private Sub cmbView_Click()
    ' 设置 ListView.View 属性。
    lvwDB.View = cmbView.ListIndex
End Sub

Private Function FindBiblio() As String
    On Error GoTo ErrHandler

    ' 在 Biblio.mdb 不能找到的情况下,配置命令对话框。
    With dlgDialog
        .DialogTitle = "不能找到 Biblio.mdb"
        .Filter = "(*.MDB)|*.mdb"
    End With

    '如果用户点击“取消”按钮将导致错误。
    dlgDialog.CancelError = True
    dlgDialog.ShowOpen
        
    Do While UCase(Right(Trim(dlgDialog.Filename), 10)) <> "BIBLIO.MDB"
       MsgBox "文件名称与 BIBLIO.MDB 不符。"
       dlgDialog.ShowOpen
    Loop
    
    FindBiblio = dlgDialog.Filename
    Exit Function
ErrHandler:
    If Err = 32755 Then
      End
    End If
End Function


Private Sub Form_Load()
    
    ' 首先打开全局的 Connection 对象。
    On Error GoTo errFind
    Set cn = New ADODB.Connection
    ' ConnectionString 包含数据库路径。如果
    ' Biblio.mdb 不存在与您的机器上,您可以在 MSDN CD 上查找。
    
    With cn
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & _
        "D:\ND2000\DATA\Eletricity.Mdb"

'        "e:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb"
        .Open
    End With
    
    ' Configure cmbView control.
    With cmbView
        .AddItem "大图标"         ' 0
        .AddItem "小图标"    ' 1
        .AddItem "列表"         ' 2
        .AddItem "详细列表"       ' 3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -