Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Show data in treeview in four levels/nodes
Message
From
07/04/2008 22:31:42
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Show data in treeview in four levels/nodes
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01308912
Message ID:
01308912
Views:
63
Dear Experts

Master.dbf has two fields as

code c(7)
desc c(30)

Data in table is as follows

1
11
1101
1101001

How to show data in Treeview in FOUR Levels/Nodes.

Please modfiy following codes or suggest some others.

Thanks in advance
CREATE cursor mytable (code n(6), node N(6),child N(6),desc c(30))
APPEND from dbf('master')

SELECT mytable
REPLACE all child with val(substr(alltrim(str(code)),4,6))
REPLACE all node with val(substr(alltrim(str(code)),1,3))
REPLACE all child with 0 for(substr(alltrim(str(code)),4,6))="000"

SELECT ;
	'_'+Padl(Node,5,'0')+Padl(Child,5,'0') As NodeId,;
	Iif(Child=0,space(11),'_'+Padl(Node,5,'0')+Padl(0,5,'0')) As ParentID,;
	desc As NodeText,TRIM(STR(code)) as code  ;
	from mytable ;
	order By 1 ;
	into Cursor myTree

SELECT myTree
#DEFINE tvwFirst	0
#DEFINE tvwLast		1
#DEFINE tvwNext		2
#DEFINE tvwPrevious	3
#DEFINE tvwChild	4

WITH Thisform.OleTreeView.Nodes
	SCAN
		IF Empty(ParentID)
			oNode = .Add(,tvwFirst,NodeId,code+ ' '+Trim(NodeText))
			oNode.ForeColor = RGB(0,0,0)
		ELSE
			oNode = .Add(ParentID,tvwChild,NodeId,code +' 

'+Trim(NodeText))
			oNode.ForeColor = RGB(0,0,255)
		ENDIF
	ENDSCAN
ENDWITH
Next
Reply
Map
View

Click here to load this message in the networking platform