home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / treevwx / tvx3demo.exe / data.1 / Main.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-01  |  7.9 KB  |  255 lines

  1. VERSION 5.00
  2. Object = "{DB625B91-05EA-11D2-97DD-00400520799C}#3.0#0"; "PVTREEX.OCX"
  3. Begin VB.Form Main 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "TreeViewX Sample"
  6.    ClientHeight    =   5430
  7.    ClientLeft      =   2055
  8.    ClientTop       =   1380
  9.    ClientWidth     =   7260
  10.    Icon            =   "Main.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    PaletteMode     =   1  'UseZOrder
  15.    ScaleHeight     =   5430
  16.    ScaleMode       =   0  'User
  17.    ScaleWidth      =   7077.74
  18.    ShowInTaskbar   =   0   'False
  19.    Begin PVTreeView3Lib.PVTreeViewX PVTreeViewX1 
  20.       Height          =   4095
  21.       Left            =   120
  22.       TabIndex        =   7
  23.       Top             =   960
  24.       Width           =   4335
  25.       _Version        =   196608
  26.       _ExtentX        =   7646
  27.       _ExtentY        =   7223
  28.       _StockProps     =   237
  29.       Appearance      =   1
  30.       DataMember      =   ""
  31.       DataField0      =   ""
  32.       DataField1      =   ""
  33.       DataField2      =   ""
  34.       DataField3      =   ""
  35.       DataField4      =   ""
  36.       DataField5      =   ""
  37.       DataField6      =   ""
  38.       DataField7      =   ""
  39.       DataField8      =   ""
  40.       DataField9      =   ""
  41.       DataField10     =   ""
  42.       DataField11     =   ""
  43.       DataField12     =   ""
  44.       DataField13     =   ""
  45.       DataField14     =   ""
  46.       DataField15     =   ""
  47.       DataField16     =   ""
  48.       DataField17     =   ""
  49.       DataField18     =   ""
  50.       DataField19     =   ""
  51.    End
  52.    Begin VB.CommandButton ChangeText 
  53.       Caption         =   "Change Selected Node's Text"
  54.       Height          =   495
  55.       Left            =   4680
  56.       TabIndex        =   5
  57.       Top             =   4560
  58.       Width           =   2295
  59.    End
  60.    Begin VB.CommandButton AddRootNode 
  61.       Caption         =   "Add Root Node"
  62.       Height          =   495
  63.       Left            =   4680
  64.       TabIndex        =   4
  65.       Top             =   3840
  66.       Width           =   2295
  67.    End
  68.    Begin VB.CommandButton InsertNewNode 
  69.       Caption         =   "Insert New Node"
  70.       Height          =   495
  71.       Left            =   4680
  72.       TabIndex        =   3
  73.       Top             =   3120
  74.       Width           =   2295
  75.    End
  76.    Begin VB.CommandButton DeleteCurrentNode 
  77.       Caption         =   "Delete Current Node"
  78.       Height          =   495
  79.       Left            =   4680
  80.       TabIndex        =   2
  81.       Top             =   2400
  82.       Width           =   2295
  83.    End
  84.    Begin VB.CommandButton SelectNextNode 
  85.       Caption         =   "Select Next Node"
  86.       Height          =   495
  87.       Left            =   4680
  88.       TabIndex        =   1
  89.       Top             =   1680
  90.       Width           =   2295
  91.    End
  92.    Begin VB.CommandButton SelectPreviousNode 
  93.       Caption         =   "Select Previous Node"
  94.       Height          =   495
  95.       Left            =   4680
  96.       TabIndex        =   0
  97.       Top             =   960
  98.       Width           =   2295
  99.    End
  100.    Begin VB.Label Label1 
  101.       Caption         =   $"Main.frx":030A
  102.       Height          =   495
  103.       Left            =   120
  104.       TabIndex        =   6
  105.       Top             =   120
  106.       Width           =   6855
  107.    End
  108. Attribute VB_Name = "Main"
  109. Attribute VB_GlobalNameSpace = False
  110. Attribute VB_Creatable = False
  111. Attribute VB_PredeclaredId = True
  112. Attribute VB_Exposed = False
  113. Private Sub AddRootNode_Click()
  114. Dim root As PVBranch
  115. Dim NewNode As PVBranch
  116. Set root = PVTreeViewX1.Branches
  117. Set NewNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  118. NewNode.Select pvtSelectNode
  119. Dim ret As String
  120. ret = InputBox("Enter text for item", "Caption", NewNode.Text)
  121. If (ret <> "") Then
  122.    NewNode.Text = ret
  123. End If
  124. End Sub
  125. Private Sub Command6_Click()
  126. End Sub
  127. Private Sub ChangeText_Click()
  128. Dim ret As String
  129. Dim selnode As PVBranch
  130. Set selnode = PVTreeViewX1.Branches.Get(pvtGetNextSelected, 0)
  131. If (selnode Is Nothing) Then Exit Sub
  132. If (selnode.IsValid = False) Then Exit Sub
  133. ret = InputBox("Enter text for item", "Caption", selnode.Text)
  134. If (ret <> "") Then
  135.    selnode.Text = ret
  136. End If
  137. End Sub
  138. Private Sub DeleteCurrentNode_Click()
  139. Dim root As PVBranch
  140. Dim node As PVBranch
  141. Dim NextNode As PVBranch
  142. Set root = PVTreeViewX1.Branches
  143. Set node = root.Get(pvtGetChild, 0)
  144. If (node.IsValid) Then
  145.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  146.    If (NextNode.IsValid) Then
  147.       NextNode.Remove
  148.    End If
  149. End If
  150. End Sub
  151. Private Sub Form_Load()
  152. Dim root As PVBranch
  153. Dim ParentNode As PVBranch
  154. Dim ChildNode As PVBranch
  155. PVTreeViewX1.AutoOpen = True
  156. PVTreeViewX1.AlwaysShowSelection = True
  157. Set root = PVTreeViewX1.Branches
  158. Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  159. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  160. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  161. Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node")
  162. ParentNode.Select pvtSelectNode
  163. Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  164. Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node")
  165. End Sub
  166. Private Sub InsertNewNode_Click()
  167. Dim root As PVBranch
  168. Dim node As PVBranch
  169. Dim NextNode As PVBranch
  170. Dim NewNode As PVBranch
  171. Set root = PVTreeViewX1.Branches
  172. Set node = root.Get(pvtGetChild, 0)
  173. If (node.IsValid) Then
  174.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  175.    If (NextNode.IsValid) Then
  176.       Set NewNode = NextNode.Add(pvtPositionInOrder, 0, "New Node")
  177.       NewNode.Select pvtSelectNode
  178.    Else
  179.       Set NewNode = node.Add(pvtPositionInOrder, 0, "Child Node")
  180.       NewNode.Select pvtSelectNode
  181.    End If
  182.    Set NewNode = root.Add(pvtPositionInOrder, 0, "Parent Node")
  183.    NewNode.Select pvtSelectNode
  184. End If
  185. Dim ret As String
  186. ret = InputBox("Enter text for item", "Caption", NewNode.Text)
  187. If (ret <> "") Then
  188.    NewNode.Text = ret
  189. End If
  190. End Sub
  191. Private Sub PVTreeViewX1_KeyDown(KeyCode As Integer, Shift As Integer)
  192. If (KeyCode = vbKeyLeft Or KeyCode = vbKeyDelete) Then
  193.    DeleteCurrentNode_Click
  194. End If
  195. If (KeyCode = vbKeyRight Or KeyCode = vbKeyInsert) Then
  196.    InsertNewNode_Click
  197. End If
  198. If (KeyCode = vbKeyReturn) Then
  199.    Set root = PVTreeViewX1.Branches
  200.     Set node = root.Get(pvtGetChild, 0)
  201.    If (node.IsValid) Then
  202.       Set NextNode = node.Get(pvtGetNextSelected, 0)
  203.       If (NextNode.IsValid) Then
  204.          PVTreeViewX1.BeginInPlaceEdit
  205.       End If
  206.    End If
  207. End If
  208. End Sub
  209. Private Sub SelectNextNode_Click()
  210. Dim root As PVBranch
  211. Dim node As PVBranch
  212. Dim NextNode As PVBranch
  213. Set root = PVTreeViewX1.Branches
  214. Set node = root.Get(pvtGetChild, 0)
  215. If (node.IsValid) Then
  216.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  217.    If (NextNode.IsValid = True) Then
  218.       Rem get the next item in the tree
  219.       Set node = NextNode.Get(pvtGetNextVisible, 0)
  220.       If (node.IsValid = True) Then
  221.          node.Select pvtSelectNode
  222.       Else
  223.          Rem we are at the last item in the tree
  224.       End If
  225.    Else
  226.       Rem select the first item in the tree
  227.       node.Select pvtSelectNode
  228.    End If
  229.    Rem no items in tree, do nothing
  230. End If
  231. End Sub
  232. Private Sub SelectPreviousNode_Click()
  233. Dim root As PVBranch
  234. Dim node As PVBranch
  235. Dim NextNode As PVBranch
  236. Set root = PVTreeViewX1.Branches
  237. Set node = root.Get(pvtGetChild, 0)
  238. If (node.IsValid) Then
  239.    Set NextNode = node.Get(pvtGetNextSelected, 0)
  240.    If (NextNode.IsValid) Then
  241.       Rem get the previous item in the tree
  242.       Set node = NextNode.Get(pvtGetPrevVisible, 0)
  243.       If (node.IsValid = True) Then
  244.          node.Select pvtSelectNode
  245.       Else
  246.          Rem we are at the first item in the tree
  247.       End If
  248.    Else
  249.       Rem select the first item in the tree
  250.       node.Select pvtSelectNode
  251.    End If
  252.    Rem no items in tree, do nothing
  253. End If
  254. End Sub
  255.