各位大虾:
    小弟遇到一个非常棘手的问题。
    在做打印发票的时候,发现打印是竖着打印的,所以在设置报表的时候要让文字旋转90度,竖着排列,请问各位大虾,这问题咋实现呢?
    小弟 急急急急!!!!!!!!!!!!!

解决方案 »

  1.   

    Printer.Orientation = valuevalue 的设置值为:常数 值 描述 
    VbPRORPortrait 1 以纸的窄边作顶部(纵向)
    VbPRORLandscape 2 以纸的宽边作顶部(横向) 
      

  2.   

    但我不是使用Printer对象
    怎么办?
      

  3.   

    在程序中如下设置
        Printer.Orientation = VbPRORLandscape
    系统会报错,说是无效的属性值
    如果设为 VbPRORPortrait 就可以
    这到底是怎么回事啊?
      

  4.   

    Option ExplicitDim adoConnectionX As New ADODB.Connection
    Dim adoRecordsetX As New ADODB.RecordsetPrivate Sub DataReport_Initialize()
      'printer.Orientation =
      '以下准备数据源(记录集)
      '要打印的数据源(记录集)必须是一个全局级别的,或者是本设计器模块级别的记录集
      
      '数据库使用的是 Northwind.mdb
      adoConnectionX.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\Northwind.mdb"
      adoRecordsetX.Open "select * from 产品", adoConnectionX
        
      Set DataReport1.DataSource = adoRecordsetX '设置 DataReport 的数据源
      
      '-------------------------------------------------------------------------
      '以下根据控件所在区域(Sections)和所属控件类别等将它们分成若干集合
      
      Dim PHSec2_RptLbl_Collection As New Collection '页标头(PageHeader)区域 Label(RptLabel) 控件集合
      Dim DSec1_RptLbl_Collection As New Collection  '细节(Detail)区域 Label(RptLabel) 控件集合
      Dim PFSec3_RptLbl_Collection As New Collection '页注脚(PageFooter)区域 Label(RptLabel) 控件
      
      Dim PHSec2_RptShp_Collection As New Collection '页标头(PageHeader)区域 Shape(RptShape) 控件集合
      Dim DSec1_RptShp_Collection As New Collection  '细节(Detail)区域 Shape(RptShape) 控件集合
      Dim PFSec3_RptShp_Collection As New Collection '页注脚(PageFooter)区域 Shape(RptShape) 控件集合
      
      Dim DSec1_RptTxt_Collection As New Collection  '细节(Detail)区域  TextBox(RptTextBox) 控件集合
                                                     'TextBox (RptTextBox) 控件只能绘制到细节(Detail)区域
      
      Dim PHSec2_RptImg_Collection As New Collection '页标头(PageHeader)区域 Image(RptImage) 控件集合
      Dim DSec1_RptImg_Collection As New Collection  '细节(Detail)区域 Image(RptImage) 控件集合
      Dim PFSec3_RptImg_Collection As New Collection '页注脚(PageFooter)区域 Image(RptImage) 控件集合
      
      Dim PHSec2_RptLine_Collection As New Collection '页标头(PageHead)区域 Line(RptLine) 控件集合
      Dim DSec1_RptLine_Collection As New Collection  '细节(Detail)区域 Line(RptLine) 控件集合
      Dim PFSec3_RptLine_Collection As New Collection '页注脚(PageFooter)区域 Line(RptLine) 控件集合
      
      Dim Ctl 'As Object
      
      For Each Ctl In DataReport1.Sections.Item("Section2").Controls  'Section2
        Select Case TypeName(Ctl)
          Case "RptLabel"
            PHSec2_RptLbl_Collection.Add Ctl
            Ctl.Caption = ""
          Case "RptShape"
            PHSec2_RptShp_Collection.Add Ctl
          Case "RptLine"
            PHSec2_RptLine_Collection.Add Ctl
          Case "RptImage"
            PHSec2_RptImg_Collection.Add Ctl
        End Select
        Ctl.Left = 0
        Ctl.Top = 0
        Ctl.Height = 300
        Ctl.Width = (Rnd + 1) * 600
        Ctl.Visible = False
      Next Ctl
      
      For Each Ctl In DataReport1.Sections.Item("Section1").Controls  'Section1
               Select Case TypeName(Ctl)
                      Case "RptLabel"
                           DSec1_RptLbl_Collection.Add Ctl
                           Ctl.Caption = ""
                      Case "RptShape"
                           DSec1_RptShp_Collection.Add Ctl
                      Case "RptTextBox"
                           Ctl.DataField = adoRecordsetX.Fields.Item(0).Name '先将所有TextBox(RptTextBox) 控件绑定到某一字段
                                                                             '否则报错!
                           DSec1_RptTxt_Collection.Add Ctl
                      Case "RptLine"
                           DSec1_RptLine_Collection.Add Ctl
                      Case "RptImage"
                           DSec1_RptImg_Collection.Add Ctl
               End Select
               Ctl.Left = 0
               Ctl.Top = 0
               Ctl.Height = 400
               Ctl.Width = 600
               Ctl.Visible = False
      Next Ctl
      
      For Each Ctl In DataReport1.Sections.Item("Section3").Controls  'Section3
               Select Case TypeName(Ctl)
                      Case "RptLabel"
                           PFSec3_RptLbl_Collection.Add Ctl
                           Ctl.Caption = ""
                      Case "RptShape"
                           PFSec3_RptShp_Collection.Add Ctl
                      Case "RptLine"
                           PFSec3_RptLine_Collection.Add Ctl
                      Case "RptImage"
                           PFSec3_RptImg_Collection.Add Ctl
               End Select
               Ctl.Left = 0
               Ctl.Top = 0
               Ctl.Height = 400
               Ctl.Width = (Rnd + 1) * 600
               Ctl.Visible = False
      Next Ctl
      '------------------------------------------------------------------------