TreeView를 구성하기 위해 아래 소스와 같이 재귀호출함수를 만들었습니다.
소스에서 Table1에 대한 내용을 조금 설명하자면 다음과 같습니다.
Table1의
ParentCode는 부모가 되는 품목의 코드
Childcode는 자식이 되는 품목의 코드
Childname은 LookUp필드로 ChildCode로 연결된 품목DB의 품목명입니다.
일종의 Child품목이 모여 Parent품목을 구성하는 것 입니다.
사실 제가하려는 것은 BOM List라는 것을 Tree구조로 작성하려고 하고 있습니다.
그런데 다음 함수를 실행하면 아무런 메세지없이 기냥 다운되어 버리더군요.
그래서 Trace를 해보았는데 어느 정도 이상없이 돌아가다가는 또 아무런 에러없이
기냥 다운되어 버립니다.
도데체 무엇이 잘못됬는지 모르겠군요...-_-;
아시는 분은 꼭좀 알려 주세요...
procedure MakeTree(ParentCode: String; PNode: TTreeNode);
var
CNode: TTreeNode;
NodeStr: String;
CurPos: TBookMark;
begin
With Form1 do
begin
Table1.First;
Table1.FindNearest([ParentCode]);
while Table1ParentCode.Value = ParentCode do
begin
NodeStr := Table1ChildCode.Value +'('+Table1ChildName.Value+')';
if PNode = nil then
CNode := BomTree.Items.add(nil, NodeStr)
else CNode := BomTree.Items.AddChildObject(PNode, NodeStr, nil);
CurPos := Table1.GetBookmark;
MakeTree(Table1ChildCode.Value, CNode);
Table1.GotoBookmark(CurPos);
Table1.FreeBookmark(CurPos);
Table1.Next;
if Table1.EOF then Exit;
end;
end;
end;
|