Показать сообщение отдельно
  #7  
Старый 06.08.2010, 18:50
Rose_Tyler Rose_Tyler вне форума
Прохожий
 
Регистрация: 06.08.2010
Сообщения: 1
Репутация: 10
По умолчанию

Та же проблема.
Из процедуры:
Код:
Select -g.GroupID,
          null as Parent,
          g.GroupCode,
          g.GroupName
From   Group g  -- группа
UNION ALL
Select sg.SubGroupID as GroupID,
         -wg.GroupID as Parent,
         sg.SubGroupCode as GroupCode,
         sg.SubGroupName as GroupName
From   SubGroup sg  -- подгруппа
нужно построить дерево в TreeView.
Я использую следующий код:
Код:
procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  try 
    // получение набора данных ADOStoredProc
  except
    // 
  end;
   // строим дерево
  ADOStoredProc.First;
  TreeView.Items.AddObject(nil, ADOStoredProc['GroupName'],
     Pointer(Integer(ADOStoredProc['GroupID'])));
  ADOStoredProc.Next;
  while  not ADOStoredProc.Eof do
  begin
    i:=0;
    while i < TreeView.Items.Count do
    begin
      if TreeView.Items.Item[i].Data = 
        Pointer(Integer(ADOStoredProc['Parent'])) then
        TreeView.Items.AddChildObject(TreeView.Items.Item[i],
           ADOStoredProc['GroupName']),
           Pointer(Integer(ADOStoredProc['GroupID'])))
      else
        Inc(i);
      ADOStoredProc.Next;
    end;
  end;
end;

Все бы ничего, но дерево почему-то состоит из одной веточки.


Помогите найти ошибку.
Ответить с цитированием