delphi treeview 控件如何数据竖向居中显示就像二叉树一样首节点最上方居中子节点依次在下方
如图:
或者有什么第三方控件也可以

解决方案 »

  1.   

    同意楼上,自己绘制,思路如下://1、确定根节点位置(矩形区域),定义为 ParentRect
    //则矩形宽度 
    W := ParentRect.Right-Parent.Left;
    //高度
    H := ParentRect.Bottom-Parent.Top;
    //为便于计算和理解,声明一个变量tmpW,表示宽度的一半
    tmpW := W div 2;//2、计算子节点位置,定义为ChildRect。假如子节点数目为n,节点的位置序号为index,则:
    //(1)计算矩形的Top、Bottom
    ChildRect.Top := ParentRect.Bottom;
    ChildRect.Bottom := ChildRect.Top+H;//(2)计算所有子节点最左边的位置L
    L := ParentRect.Left-((n-1)*tmpW);
    //(3)计算所有子节点Left、Right
    for Index := 0 to n-1 do begin
      ChildRect[index].Left := L+W*index;
      ChildRect[index].Right := ChildRect[index].Left+W;
    end;
    //3、递归调用第2步,即可计算出全部节点的矩形区域
    //4、重新计算所有节点的实际绘制区域,留出间隔位置,如:
    ChildDrawRect := ChildRect;
    With ChildDrawRect do begin
      Top := Top + (H div 6);
      Bottom := Bottom - (H div 6);
      Left := Left + (W div 6);
      Right := Right - (W div 6);
    end;
    //5、绘制子节点与父节点的连接线(略)