home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axtree / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-01-14  |  9.9 KB  |  319 lines

  1. VERSION 5.00
  2. Object = "{277255B2-5EBD-11D2-BF5B-00A024982E5B}#10.0#0"; "axTree.ocx"
  3. Begin VB.Form Form1 
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Form1"
  6.    ClientHeight    =   4860
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   6510
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4860
  12.    ScaleWidth      =   6510
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin axTreeControl.axTree axTree1 
  15.       Height          =   3795
  16.       Left            =   315
  17.       TabIndex        =   0
  18.       Top             =   225
  19.       Width           =   3435
  20.       _ExtentX        =   6059
  21.       _ExtentY        =   6694
  22.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  23.          Name            =   "MS Sans Serif"
  24.          Size            =   8.25
  25.          Charset         =   0
  26.          Weight          =   400
  27.          Underline       =   0   'False
  28.          Italic          =   0   'False
  29.          Strikethrough   =   0   'False
  30.       EndProperty
  31.       Count           =   4
  32.       List_11         =   ""
  33.       List_21         =   "Level1"
  34.       List_31         =   -1
  35.       List_41         =   -1  'True
  36.       List_51         =   0
  37.       List_61         =   0
  38.       List_71         =   0
  39.       List_81         =   0
  40.       List_91         =   -1
  41.       List_101        =   0
  42.       List_12         =   ""
  43.       List_22         =   "SubLevel1"
  44.       List_32         =   -1
  45.       List_42         =   0   'False
  46.       List_52         =   0
  47.       List_62         =   1
  48.       List_72         =   0
  49.       List_82         =   0
  50.       List_92         =   -1
  51.       List_102        =   1
  52.       List_13         =   ""
  53.       List_23         =   "SubLevel2"
  54.       List_33         =   -1
  55.       List_43         =   0   'False
  56.       List_53         =   0
  57.       List_63         =   1
  58.       List_73         =   0
  59.       List_83         =   0
  60.       List_93         =   -1
  61.       List_103        =   2
  62.       List_14         =   ""
  63.       List_24         =   "Level2"
  64.       List_34         =   -1
  65.       List_44         =   0   'False
  66.       List_54         =   0
  67.       List_64         =   0
  68.       List_74         =   0
  69.       List_84         =   0
  70.       List_94         =   -1
  71.       List_104        =   3
  72.    End
  73.    Begin VB.CommandButton Command1 
  74.       Caption         =   "Show All Selected"
  75.       Height          =   420
  76.       Index           =   15
  77.       Left            =   5265
  78.       TabIndex        =   16
  79.       Top             =   3105
  80.       Width           =   1185
  81.    End
  82.    Begin VB.CommandButton Command1 
  83.       Caption         =   "ParentIndex"
  84.       Height          =   420
  85.       Index           =   14
  86.       Left            =   3960
  87.       TabIndex        =   15
  88.       Top             =   3105
  89.       Width           =   1185
  90.    End
  91.    Begin VB.CommandButton Command1 
  92.       Caption         =   "Add Before"
  93.       Height          =   420
  94.       Index           =   13
  95.       Left            =   3960
  96.       TabIndex        =   14
  97.       Top             =   1125
  98.       Width           =   1185
  99.    End
  100.    Begin VB.CommandButton Command1 
  101.       Caption         =   "NewIndex"
  102.       Height          =   420
  103.       Index           =   10
  104.       Left            =   5265
  105.       TabIndex        =   13
  106.       Top             =   1125
  107.       Width           =   1185
  108.    End
  109.    Begin VB.CommandButton Command1 
  110.       Caption         =   "Expand Node"
  111.       Height          =   420
  112.       Index           =   12
  113.       Left            =   3960
  114.       TabIndex        =   12
  115.       Top             =   2610
  116.       Width           =   1185
  117.    End
  118.    Begin VB.CommandButton Command1 
  119.       Caption         =   "Collapse Node"
  120.       Height          =   420
  121.       Index           =   11
  122.       Left            =   5265
  123.       TabIndex        =   11
  124.       Top             =   2610
  125.       Width           =   1185
  126.    End
  127.    Begin VB.CommandButton Command1 
  128.       Caption         =   "Change Node"
  129.       Height          =   420
  130.       Index           =   9
  131.       Left            =   5265
  132.       TabIndex        =   10
  133.       Top             =   1620
  134.       Width           =   1185
  135.    End
  136.    Begin VB.CommandButton Command1 
  137.       Caption         =   "Add After"
  138.       Height          =   420
  139.       Index           =   8
  140.       Left            =   5265
  141.       TabIndex        =   9
  142.       Top             =   630
  143.       Width           =   1185
  144.    End
  145.    Begin VB.CommandButton Command1 
  146.       Caption         =   "Find Line"
  147.       Height          =   420
  148.       Index           =   7
  149.       Left            =   5265
  150.       TabIndex        =   8
  151.       Top             =   3600
  152.       Width           =   1185
  153.    End
  154.    Begin VB.CommandButton Command1 
  155.       Caption         =   "Find Item"
  156.       Height          =   420
  157.       Index           =   6
  158.       Left            =   3960
  159.       TabIndex        =   7
  160.       Top             =   3600
  161.       Width           =   1185
  162.    End
  163.    Begin VB.CommandButton Command1 
  164.       Caption         =   "Collapse All"
  165.       Height          =   420
  166.       Index           =   5
  167.       Left            =   5265
  168.       TabIndex        =   6
  169.       Top             =   2115
  170.       Width           =   1185
  171.    End
  172.    Begin VB.CommandButton Command1 
  173.       Caption         =   "Expand All"
  174.       Height          =   420
  175.       Index           =   4
  176.       Left            =   3960
  177.       TabIndex        =   5
  178.       Top             =   2115
  179.       Width           =   1185
  180.    End
  181.    Begin VB.CommandButton Command1 
  182.       Caption         =   "Add Node"
  183.       Height          =   420
  184.       Index           =   3
  185.       Left            =   3960
  186.       TabIndex        =   4
  187.       Top             =   630
  188.       Width           =   1185
  189.    End
  190.    Begin VB.CommandButton Command1 
  191.       Caption         =   "Delete Node"
  192.       Height          =   420
  193.       Index           =   2
  194.       Left            =   3960
  195.       TabIndex        =   3
  196.       Top             =   1620
  197.       Width           =   1185
  198.    End
  199.    Begin VB.CommandButton Command1 
  200.       Caption         =   "Count"
  201.       Height          =   420
  202.       Index           =   1
  203.       Left            =   5265
  204.       TabIndex        =   2
  205.       Top             =   135
  206.       Width           =   1185
  207.    End
  208.    Begin VB.CommandButton Command1 
  209.       Caption         =   "Selected Item"
  210.       Height          =   420
  211.       Index           =   0
  212.       Left            =   3960
  213.       TabIndex        =   1
  214.       Top             =   135
  215.       Width           =   1185
  216.    End
  217. Attribute VB_Name = "Form1"
  218. Attribute VB_GlobalNameSpace = False
  219. Attribute VB_Creatable = False
  220. Attribute VB_PredeclaredId = True
  221. Attribute VB_Exposed = False
  222. Private db As Database, rs As Recordset
  223. Private Sub axTree1_Click()
  224.   Debug.Print "click"
  225. End Sub
  226. Private Sub axTree1_NodeClick(Index As Integer)
  227.   Debug.Print "nodeclick", Str(Index)
  228. End Sub
  229. Private Sub Command1_Click(Index As Integer)
  230.   Dim msItem As String
  231.   Select Case Index
  232.   Case 0
  233.     msg = Str(axTree1.SelectedItem) + vbCr + axTree1.Item(axTree1.SelectedItem) + vbCr + IIf(axTree1.Item(axTree1.SelectedItem).Selected, "Selected", "Not Selected") + vbCr + IIf(axTree1.Item(axTree1.SelectedItem).isparent, "Parent", "Child")
  234.     MsgBox msg, vbOKOnly, "SelectedItem"
  235.   Case 1
  236.     MsgBox axTree1.Count, vbOKOnly, "Count"
  237.   Case 2
  238.     axTree1.RemoveNode axTree1.SelectedItem
  239.   Case 3
  240.     axTree1.AddNode "test" + Str(axTree1.Count + 1), 0, False
  241.   Case 4
  242.     axTree1.ExpandAll
  243.   Case 5
  244.     axTree1.CollapseAll
  245.   Case 6
  246.     msItem = InputBox("Search for item", "Search")
  247.     If msItem > "" Then
  248.       axTree1.Find msItem, 0
  249.     End If
  250.   Case 7
  251.     msItem = InputBox("Search for item", "Search", "0")
  252.     If msItem > "" Then
  253.       axTree1.SelectedItem = Val(msItem)
  254.     End If
  255.   Case 8
  256.     axTree1.AddNode "after" + Str(axTree1.Count + 1), 0, False, , axTree1.SelectedItem
  257.   Case 9
  258.     axTree1.Item(axTree1.SelectedItem).Caption = "Changed"
  259.     axTree1.Item(axTree1.SelectedItem).Selected = 1
  260.     axTree1.Refresh
  261.   Case 10
  262.     MsgBox Str(axTree1.NewIndex)
  263.   Case 11   'collapse node
  264.     msItem = InputBox("Collapse item", "Search", "0")
  265.     If msItem > "" Then
  266.       axTree1.Collapse Val(msItem)
  267.     End If
  268.   Case 12   'expand node
  269.     msItem = InputBox("Expand item", "Search", "0")
  270.     If msItem > "" Then
  271.       axTree1.Expand Val(msItem)
  272.     End If
  273.   Case 13
  274.     axTree1.AddNode "before" + Str(axTree1.Count + 1), 0, False, axTree1.SelectedItem
  275.   Case 14
  276.     MsgBox axTree1.ParentIndex(axTree1.SelectedItem)
  277.   Case 15
  278.     msg = ""
  279.     For cnt = 1 To axTree1.Count
  280.       If axTree1.Item(cnt).Selected > 0 Then
  281.         msg = msg + axTree1.Item(cnt).Caption + ", " + Str(axTree1.Item(cnt).Selected) + vbCr
  282.       End If
  283.     Next
  284.     MsgBox msg
  285.   End Select
  286. End Sub
  287. Private Sub Form_Load()
  288.   Dim PrevType As String
  289.   axTree1.Clear
  290.   axTree1.AutoRefresh = False
  291.   'open the database and create the recordset
  292.   Set db = OpenDatabase(App.Path & "\TestSet.mdb")
  293.   Set rs = db.OpenRecordset("Select * from Address inner join ContactType on Address.ContactType = ContactType.TypeId Order By TypeName, LastName")
  294.   PrevType = ""
  295.   rs.MoveFirst
  296.   Do Until rs.EOF
  297.     If PrevType <> rs("TypeName") Then
  298.       axTree1.AddNode rs("TypeName"), 0, True
  299.       PrevType = rs("TypeName")
  300.     End If
  301.     axTree1.AddNode rs("LastName"), 1, False
  302.     rs.MoveNext
  303.   Loop
  304. axTree1.Item(axTree1.Count).bitmap = LoadPicture(App.Path + "\bitmaps\hlp.bmp")
  305. '  axTree1.AddNode "level0", 0, False, , , , , LoadPicture(App.Path + "/bitmaps/hlp.bmp")
  306. '  axTree1.AddNode "level1", 1, True
  307. '  axTree1.AddNode "level2", 2, True
  308. '  axTree1.AddNode "level3", 3, True
  309. '  axTree1.AddNode "level4", 4, True
  310. '  axTree1.AddNode "level5", 5, True
  311. '  axTree1.AddNode "level6", 6, True
  312. '    axTree1.AddNode "level7", 7, False
  313. axTree1.AutoRefresh = True
  314.   axTree1.CollapseAll
  315. 'axTree1.Refresh
  316.   Set rs = Nothing
  317.   Set db = Nothing
  318. End Sub
  319.