CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  多媒体

高分求助vsview7+vsflex结合打印的例子

楼主cooldu(cooldu)2003-06-01 12:41:43 在 VB / 多媒体 提问

高分求助vsview7+vsflex结合打印的例子  
  不要安装文件自带的,要求有表格,页眉,页脚 问题点数:100、回复次数:3Top

1 楼caliphliao(老九)回复于 2003-06-02 15:54:59 得分 20

Private   Sub   RenderRecordset(pView   As   VSPrinter,   Rs   As   Recordset,   ByVal   maxh   As   Double)  
   
          Dim   Arr,   i%,   j%,   wid!  
           
          '   read   recordset   into   an   array  
          Rs.MoveLast  
          Rs.MoveFirst  
          i   =   Rs.RecordCount  
          If   i   =   0   Then   Exit   Sub  
           
          Arr   =   Rs.GetRows(i)  
   
          '   create   table   header   and   dummy   format  
          Dim   fmt$,   hdr$  
          Dim   fldList   As   Variant  
          fldList   =   SplitString(GetFldCaption(Rs))  
          For   i   =   0   To   Rs.Fields.Count   -   1  
                  If   i   >   0   Then   hdr   =   hdr   &   "|"  
                  fmt   =   fmt   &   "|"  
                  hdr   =   hdr   &   fldList(i)  
                  fmt   =   fmt   &   500  
          Next  
           
          '   create   table  
          pView.StartTable  
          pView.AddTableArray   fmt,   hdr,   Arr  
           
          '   format   table  
          For   i   =   0   To   Rs.Fields.Count   -   1  
           
                  '   right-align   numbers   and   dates  
                  Select   Case   Rs.Fields(i).Type  
                          Case   5   '數據型  
                                                  pView.TableCell(tcColAlign,   ,   i   +   1)   =   taRightMiddle  
                            Case   Else  
                                                  pView.TableCell(tcColAlign,   ,   i   +   1)   =   ttaLeftMiddle  
                End   Select  
                   
                  '   set   column   width  
                  If   Rs.Fields(i).Type   =   dbMemo   Then  
                          pView.TableCell(tcColWidth,   ,   i   +   1)   =   "2.5in"  
                  Else  
                          fmt   =   ""  
                          For   j   =   0   To   UBound(Arr,   2)  
                                          If   j   >   100   Then   Exit   For  
                                          If   Len(fmt)   <   Len(Arr(i,   j))   Then  
                                                  fmt   =   Arr(i,   j)  
                                          End   If  
                          Next  
                          If   Len(fldList(i))   >   Len(fmt)   Then  
                                  fmt   =   fldList(i)  
                          End   If  
                          pView.TableCell(tcColWidth,   ,   i   +   1)   =   pView.TextWidth(fmt)   *   2  
              End   If  
          Next  
           
          '   format   header   row   (0)  
          pView.TableCell(tcFontBold,   0)   =   True  
          pView.TableCell(tcBackColor,   0)   =   vbYellow  
          pView.TableCell(tcRowHeight,   0)   =   pView.TextHeight("Test")   *   1.1  
          pView.TableCell(tcAlign,   0)   =   taLeftMiddle  
           
          '   make   sure   it   all   fits  
          For   i   =   1   To   pView.TableCell(tcCols)  
                  wid   =   wid   +   pView.TableCell(tcColWidth,   ,   i)  
          Next  
          pView.GetMargins  
          If   wid   >   pView.X2   -   pView.X1   Then  
                  wid   =   (pView.X2   -   pView.X1)   /   wid   *   0.95  
                  For   i   =   1   To   pView.TableCell(tcCols)  
                          pView.TableCell(tcColWidth,   ,   i)   =   wid   *   pView.TableCell(tcColWidth,   ,   i)  
                  Next  
          End   If  
           
          '   honor   maximum   row   height  
          If   maxh   >   0   Then  
                  For   i   =   1   To   pView.TableCell(tcRows)  
                          If   pView.TableCell(tcRowHeight,   i)   >   maxh   Then  
                                  pView.TableCell(tcRowHeight,   i)   =   maxh  
                          End   If  
                  Next  
          End   If  
           
          '   done   with   table  
          pView.EndTable  
   
  End   Sub  
   
   
  Public   Sub   vReport(Rs   As   ADODB.Recordset)  
  '  
  '   record   source   changed,   get   new   recordset   and   render   it  
  '  
          MousePointer   =   vbHourglass  
           
          '   get   record   source   string   (trim   comments   up   to   ":")  
  '         Dim   s$,   i%  
  '         s   =   cmbSource  
  '         i   =   InStr(s,   ":")  
  '         If   i   >   0   Then   s   =   Trim(Mid(s,   i   +   1))  
           
          '   get   recordset  
           
          '   create   document  
          With   pView  
                   
                  '   set   up  
                  .FontName   =   "Tahoma"  
                  .FontSize   =   9  
                  .PenColor   =   RGB(190,   190,   190)  
                  .Footer   =   "有限公司|Page   %d"  
  '                 .PageBorder   =   pbColBottom       '底線  
                  .StartDoc  
                   
                  '   show   title  
                  .Paragraph   =   "標題"  
   
                  .FontBold   =   True  
                  .FontBold   =   False  
                  .Paragraph   =   ""  
                   
                  '   render   recordset   (this   is   the   main   routine   here)  
                  RenderRecordset   pView,   Rs,   0  
                   
                  '   done  
                  .EndDoc  
                  .ScrollIntoView   0,   0  
          End   With  
   
          MousePointer   =   vbDefault  
   
  End   Sub  
   
  Private   Sub   Form_Load()  
                          pView.MarginLeft   =   60  
                          pView.MarginBottom   =   1440  
                          pView.MarginRight   =   60  
                          pView.MarginTop   =   1440  
  End   Sub  
   
  Private   Sub   Form_Resize()  
                  pView.Height   =   ScaleHeight   -   20  
                  pView.Top   =   10  
                  pView.Left   =   10  
                  pView.Width   =   ScaleWidth   -   20  
  End   Sub  
   
  Private   Sub   Form_Unload(Cancel   As   Integer)  
  On   Error   GoTo   Form_Unload_Err  
          Set   FrmPrint   =   Nothing  
          Exit   Sub  
  Form_Unload_Err:  
          MsgBox   Me.Caption   &   "|Form_Unload:"   &   Err.Description,   vbOKOnly   +   vbCritical,   CStr(Err.Number)  
  End   Sub  
  Top

2 楼lihonggen0(李洪根,MS MVP,标准答案来了)回复于 2003-06-02 17:32:10 得分 10

http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=39769Top

3 楼verystudy(大度)回复于 2003-06-02 23:07:14 得分 70

With   pView  
                   
                  .FontName   =   "Tahoma"  
                  .FontSize   =   9  
                  .PenColor   =   RGB(190,   190,   190)  
                  .Footer   =   "有限公司|Page   %d"  
  '               .PageBorder   =   pbColBottom       '底線  
                  .StartDoc  
                   
                  '   show   title  
                  .Paragraph   =   "標題"  
   
                .penrender=vsflexgrid  
                   
                  '   done  
                  .EndDoc  
  Top

相关问题

  • 求打印的例子
  • 谁可以给一些打印例子?
  • 寻 打印/报表 的程序例子
  • 谁有MsFlexGrid的打印例子源码?
  • 关于打印的一个例子!
  • 关于打印的一个例子!
  • 200分求WINCE打印程序例子~~
  • 哪有编写打印或出条形码的例子程序
  • 例子代码:简单地判断打印机是否存在
  • 谁有动态打印的例子,急用

关键词

  • hdr
  • pview
  • tablecell
  • tccolwidth
  • wid
  • fmt
  • fldlist
  • tcrowheight
  • maxh
  • rs

得分解答快速导航

  • 帖主:cooldu
  • caliphliao
  • lihonggen0
  • verystudy

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo