怎样把目录树的内容输到报表同样以目录树的形式打印???

解决方案 »

  1.   

    用FASTREPORT做报表,先把TREEVIEW的内容保存为文本,然后在FASTREPORT里画出来
      

  2.   

    type
      TThickness = -1..+1;const
      cGBGridList: array[TThickness, TThickness, TThickness, TThickness] of WideString =
    ((
    (('┼', '├', '┽'), ('┴', '└', '┵'), ('╁', '┟', '╅')),
    (('┤', '│', '┥'), ('┘', '↑', '┙'), ('┧', '︾', '┪')),
    (('┾', '┝', '┿'), ('┶', '┕', '┷'), ('╆', '┢', '╈'))),
    (
    (('┬', '┌', '┭'), ('─', '→', '《'), ('┰', '┎', '┱')),
    (('┐', '↓', '┑'), ('←', ' ', '<'), ('┒', '∨', '┓')),
    (('┮', '┍', '┯'), ('》', '>', '━'), ('┲', '┏', '┳'))),
    (
    (('╀', '┞', '╃'), ('┸', '┖', '┹'), ('╂', '┠', '╉')),
    (('┦', '︽', '┩'), ('┚', '∧', '┛'), ('┨', '┃', '┫')),
    (('╄', '┡', '╇'), ('┺', '┗', '┻'), ('╊', '┣', '╋'))));function TreeViewToDisplay(mTreeView: TTreeView; mStrings: TStrings;
      mHBold: Boolean = True; mVBold: Boolean = True): Boolean;
    { 将可视树转换成可视方式 }
    var
      I, J: Integer;
      T, S: string;
      H, V: Integer;
      vTreeNode: TTreeNode;
    begin
      Result := False;
      if not Assigned(mTreeView) then Exit;
      if not Assigned(mStrings) then Exit;
      mStrings.Clear;
      H := Iif(mHBold, +1, -1);
      V := Iif(mVBold, +1, -1);
      J := 0;
      with mTreeView do try
        for I := 0 to Pred(Items.Count) do begin
          if J > Items[I].Level then
            T := Copy(T, 1, Length(T) - (J - Items[I].Level) * 2)
          else if J < Items[I].Level then T := T + S;
          vTreeNode := Items[I].GetNextSibling;
          if not Assigned(vTreeNode) then begin
            mStrings.Add(T + cGBGridList[V, H, 00, 00] + Items[I].Text);
            S := cGBGridList[00, 00, 00, 00];
          end else begin
            mStrings.Add(T + cGBGridList[V, H, V, 00] + Items[I].Text);
            S := cGBGridList[V, 00, V, 00];
          end;
          J := Items[I].Level;
        end;
      except
        Exit;
      end;
      Result := True;
    end; { TreeViewToDisplay }
    ///////End Source///////Begin Demo
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      TreeViewToDisplay(TreeView1, Memo1.Lines, CheckBox1.Checked, CheckBox2.Checked);
    end;
    ///////End Demo
      

  3.   

    to:guowzgyc(宝兰心情)   怎么下面运行不了:
      H := Iif(mHBold, +1, -1);
      V := Iif(mVBold, +1, -1);
       会不会写错阿?谢谢你的帮忙!!!
      

  4.   

    Sorry!
    function Iif(mBool: Boolean; mDataA, mDataB: Variant): Variant;
    begin
      if mBool then
        Result := mDataA
      else Result := mDataB;
    end; { Iif }