在代码中定义的flexreport,界面中有打印按钮,点击,调用打印对话框,然后打印,但发现,在打印对话框中定义了要打印的页范围,但无效,始终打印全部页。
代码如下:
Private Sub btn_print_Click(sender As Object, e As EventArgs) Handles btn_print.Click
create_report() ‘创建报表的过程,代码略。
C1FlexReport1.Render()
'显示打印选择框
Dim pfrm As New PrintDialog
pfrm.PrinterSettings = New Printing.PrinterSettings
pfrm.AllowSomePages = True '起用页范围
pfrm.PrinterSettings.FromPage = 1'让打印对话框中的起始页为1,止页为报表的总页数。
pfrm.PrinterSettings.ToPage = C1FlexReport1.PageCount
If pfrm.ShowDialog(Me) = DialogResult.OK Then
Dim op As New C1PrintOptions()
op.PrinterSettings = New PrinterSettings
op.PageSettings = New PageSettings
Dim ps As New Printing.PaperSize("u", nwidth / 2.54 * 100, nheigh / 2.54 * 100) '定义纸尺寸。nwidth是取的变量值。
op.PageSettings.PaperSize = ps
op.PageSettings.Margins.Top = ntop / 2.54 * 100 '上边距
op.PageSettings.Margins.Left = nleft / 2.54 * 100
op.PageSettings.Margins.Bottom = ndown / 2.54 * 100
op.PageSettings.Margins.Right = nright / 2.54 * 100
op.PrinterSettings.PrinterName = pfrm.PrinterSettings.PrinterName '取选择的打印机,有效。
‘下面4行,前两行和后两行分别试了,无效。
op.PrinterSettings.FromPage = pfrm.PrinterSettings.FromPage '取打印开始页
op.PrinterSettings.ToPage = pfrm.PrinterSettings.ToPage
'op.PageSettings.PrinterSettings.FromPage = pfrm.PrinterSettings.FromPage
'op.PageSettings.PrinterSettings.ToPage = pfrm.PrinterSettings.ToPage
op.PageSettings.Landscape = True '横向打印
op.PrintJobName = "打印"
C1FlexReport1.Print(op)
End If
End Sub
又麻烦版主了,关键是我确实试了,无效。若版主需要示例,可以把我上个问题<truedbgrid打印所见即所得>里用的那个示例,修改下,加上打印按钮。
另外,可以安装Foxit Reader PDF Printer,这样,就直接打印到文件了,不用实际打印。
若版主忙,我来改,谢谢。
|
|