Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Treeview Problem
Message
From
02/04/2003 08:15:42
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/04/2003 21:49:53
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00772794
Message ID:
00772892
Views:
5
>Hi ALL
>
>I need your help with a Active X tree view problem. I have used the MegaFox Tree view from chapter 9 in my form. The two tables I am working with are company (The order is by company name) and contact table (the order is by companyid) . When I add a new company I can add it to the table. However, The tree view displays the new company at the bottom of the tree view.
>How can I fix this. Do I have to clear the tree view nodes and reload the tree view ? (how and what is the quickest way to reload the tree view) Or is there an easier way?
>
>Thank you for you help,
>
>Andy Eggers

Andy,
You can add a new node to any position w/o reloading.

#Define tvwFirst 0
#Define tvwLast 1
#Define tvwNext 2
#Define tvwPrevious 3
#Define tvwChild 4

Using tvwNext or tvwPrevious you can position the placement after or before an existing node. ie: (Bolded ones are those added later)
#Define tvwFirst	0
#Define tvwLast	1
#Define tvwNext	2
#Define tvwPrevious	3
#Define tvwChild	4

oForm = Createobject('myForm')
With oForm
  With .Tree
    .Left = 10
    .Top = 10
    .Width = 200
    .Height = 200
    .Nodes.Add(,tvwFirst,"root0",'Main node 0')
    .Nodes.Add(,tvwFirst,"root1",'Main node 1')
    .Nodes.Add(,tvwFirst,"root2",'Main node 2')

* Add 2 child nodes to root1
    .Nodes.Add('root1',tvwChild,"child11",'Child11')
    .Nodes.Add('root1',tvwChild,"child12",'Child12')
*Add a child node to root2
    .Nodes.Add('root2',tvwChild,"child23",'Child23')

    .Nodes.Add('child11',tvwChild,"child113",'child113')
    With .Nodes.Add('child113',tvwPrevious,"child112",'child112')
      .Bold=.T.
    Endwith
    With .Nodes.Add('child112',tvwPrevious,"child111",'child111')
      .Bold = .T.
    Endwith

* Later decided to add another 2 nodes to root2
* Place first before child23
    With .Nodes.Add('child23',tvwPrevious,"child22",'Child22')
      .Bold=.T.
    Endwith
* Place next before child22
    With .Nodes.Add('child22',tvwPrevious,"child21",'Child21')
      .Bold=.T.
    Endwith

    For Each oNode In .Nodes && Expand all nodes for easy view
      oNode.Expanded = .T.
    Endfor

  Endwith
  .Show()
Endwith
Read Events

Define Class myForm As Form
  ADD OBJECT Tree as OleControl WITH ;
  Name = 'Tree',OleClass='MSComCtlLib.TreeCtrl'
  
  PROCEDURE init
  With This.tree
    .linestyle = 1
    .Font.Name = 'Times New Roman'
    .Font.Size = 10
    .indentation = 5
  Endwith
  endproc

  Procedure QueryUnload
  Clear Events
Endproc
Enddefine
For a quick load (actually no load but load on demand) and some other TV processing check UT magazine first issue (June 2001?).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform