我用vsflexgrid + vsprint控件, 我怎么得到打印的总页数?

解决方案 »

  1.   

    PreviewPages能行吗?
    还有,能请你发一个vsprint打印vsflexgrid表格的例子给我吗?谢谢。
    [email protected]
      

  2.   

    Private Sub ActiveBar21_ToolClick(ByVal Tool As ActiveBar2LibraryCtl.Tool)
        Dim bOK%, sMsg$
        Select Case Tool.Name
        Case "zoomout":
            VSPrinter1.Zoom = VSPrinter1.Zoom + VSPrinter1.ZoomStep
        Case "zoomin":
            VSPrinter1.Zoom = VSPrinter1.Zoom - VSPrinter1.ZoomStep
       Case "page": '选择纸张设置
            VSPrinter1.PrintDialog (pdPageSetup)
            With VSPrinter1
                 .StartDoc
            .Zoom = 75 '显示比例
            .RenderControl = bsemployee.vg.hwnd   '把网格内容传递给vsView显示
            .EndDoc      ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
          ActiveBar21.Bands(1).Tools(1).Caption = "   共  " + Trim(str(.PageCount)) + "  页"
           If .PageCount = 1 Then
                ActiveBar21.Bands(0).Tools(0).Enabled = True
                ActiveBar21.Bands(0).Tools(1).Enabled = True
                ActiveBar21.Bands(0).Tools(3).Enabled = False
                ActiveBar21.Bands(0).Tools(4).Enabled = False
            Else
                ActiveBar21.Bands(0).Tools(0).Enabled = True
                ActiveBar21.Bands(0).Tools(1).Enabled = True
                ActiveBar21.Bands(0).Tools(3).Enabled = False
                ActiveBar21.Bands(0).Tools(4).Enabled = True
            End If
            End With
            
        Case "back": '前页
          With VSPrinter1
            If .PreviewPage > 1 Then
              .PreviewPage = .PreviewPage - 1
                If .PreviewPage = 1 Then
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = False
                  ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"              Else
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = True
                  ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
                End If
            Else
                If .PreviewPage = 1 Then
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = False
                   ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
                 Else
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = True
                  ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
                End If
            End If
          End With    Case "forward": '后页
          With VSPrinter1
            If .PreviewPage < .PageCount Then
               .PreviewPage = .PreviewPage + 1
               If .PreviewPage = .PageCount Then
                  ActiveBar21.Bands(0).Tools(3).Enabled = True
                  ActiveBar21.Bands(0).Tools(4).Enabled = False
                   ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
                 Else
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = True
                  ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
               End If
            Else
              If .PreviewPage = .PageCount Then
                 ActiveBar21.Bands(0).Tools(3).Enabled = True
                 ActiveBar21.Bands(0).Tools(4).Enabled = False
                   ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
                 Else
                  ActiveBar21.Bands(0).Tools(4).Enabled = True
                  ActiveBar21.Bands(0).Tools(3).Enabled = True
                  ActiveBar21.Bands(1).Tools(0).Caption = "   第  " + Trim(str(.PreviewPage)) + "  页"
              End If
            End If
          End With
          
          
         Case "print": '打印输出
         VSPrinter1.PrintDoc    Case "quit": Unload Me
        End Select
        End Sub
      

  3.   

    忘了说明,以上是我以前写过的一段代码: 我用ActiveBar21工具条,内含上边的按钮和下面的状态栏, 页数显示在状态栏里面,当前页和总页数都有的,供参考.
      

  4.   

    关键是:
          当前页 = "   第  " + Trim(str(.PreviewPage)) + "  页"
          总页数 = "   共  " + Trim(str(.PageCount)) + "  页"
      

  5.   

    这个是不行的,在打印进行时,PageCount得不到总页数的。
    因此你如果要在报表上添加总页数是不行的。有个傻方法,你可先提交,提交完成后,PageCount就是总页数了,把它赋值给变量V1,用V1作为总页数,再提交一次。
    没办法中的办法。