i:=0;
while i=0 do
begin
  if IfHaveDate(node) then
    i:=1
  else
     Node:=Node.Parent;
end;之所以那样写,是因为不明白你所说的数据是什么样的数据,所以
请你自己完成IfHaveDate这个函数啦

解决方案 »

  1.   

    if TreeView1.Selected.Count=0 then
       begin
          TreeView1.Selected:=TreeView1.Selected.Parent;
          ShowMessage(TreeView1.Selected.Text);
       end;
      

  2.   

    var
      ln:TTreeNode;
    begin
      ln:=treeview1.selected;
      while ln.Level>=0 do
      begin
        if ln.data<>nil then
        begin
         showmessage('找到'+ln.text);    
         exit;
        end;
        ln:=ln.parent;
      end;
      if ln=nil then showmessage('找不到');    
    end;
      

  3.   

    for i:=1 to TreeView1.Selected.Parent.Count then
    begin
      输入你的处理程序;
    end;