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

y_shen 2003-11-13 08:52:03
我用vsflexgrid + vsprint控件, 我怎么得到打印的总页数?
...全文
131 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zerg2001 2004-03-17
  • 打赏
  • 举报
回复
这个是不行的,在打印进行时,PageCount得不到总页数的。
因此你如果要在报表上添加总页数是不行的。

有个傻方法,你可先提交,提交完成后,PageCount就是总页数了,把它赋值给变量V1,用V1作为总页数,再提交一次。
没办法中的办法。


axer 2004-03-04
  • 打赏
  • 举报
回复
关键是:
当前页 = " 第 " + Trim(str(.PreviewPage)) + " 页"
总页数 = " 共 " + Trim(str(.PageCount)) + " 页"
axer 2004-03-04
  • 打赏
  • 举报
回复
忘了说明,以上是我以前写过的一段代码: 我用ActiveBar21工具条,内含上边的按钮和下面的状态栏, 页数显示在状态栏里面,当前页和总页数都有的,供参考.
axer 2004-03-04
  • 打赏
  • 举报
回复
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
planetike 2003-11-13
  • 打赏
  • 举报
回复
PreviewPages能行吗?
还有,能请你发一个vsprint打印vsflexgrid表格的例子给我吗?谢谢。
planetike@hotmail.com

809

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧