Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a grid to show parent-child relationship
Message
From
02/05/2008 14:02:57
 
 
To
02/05/2008 10:00:08
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01314635
Message ID:
01314837
Views:
14
Mo,

I asked because of the way you posed the question. I was unsure if you knew about the VFP way to do it and perferred to find another control.

Try this and see if it meets your needs. I use a browse statement in the example but it works in a grid as well.

CREATE CURSOR PTAble (PID I, PName C(50))
CREATE CURSOR CTAble (CID I, PID I, CName C(50))

SELECT PTAble
APPEND BLANK
REPLACE PID WITH 1, PName WITH "Parent 1"
APPEND BLANK
REPLACE PID WITH 2, PName WITH "Parent 2"
APPEND BLANK
REPLACE PID WITH 3, PName WITH "Parent 3"


SELECT CTAble
APPEND BLANK
REPLACE CID WITH 1, PID WITH 1, CName WITH "Child 1"
APPEND BLANK
REPLACE CID WITH 2, PID WITH 1, CName WITH "Child 2"
APPEND BLANK
REPLACE CID WITH 3, PID WITH 1, CName WITH "Child 3"

APPEND BLANK
REPLACE CID WITH 4, PID WITH 2, CName WITH "Child 4"
APPEND BLANK
REPLACE CID WITH 5, PID WITH 2, CName WITH "Child 5"
APPEND BLANK
REPLACE CID WITH 6, PID WITH 2, CName WITH "Child 6"

APPEND BLANK
REPLACE CID WITH 7, PID WITH 3, CName WITH "Child 7"
APPEND BLANK
REPLACE CID WITH 8, PID WITH 3, CName WITH "Child 8"
APPEND BLANK
REPLACE CID WITH 9, PID WITH 3, CName WITH "Child 9"

SELECT CTAble
INDEX ON PID TAG PID

SELECT PTAble
SET RELATION TO pid INTO Ctable ADDITIVE
SET SKIP TO Ctable
GO TOP
BROWSE FIELDS PTable.pid, PTable.PName, CTable.cid, CTable.cname
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform