PrintDialog问题 [英] PrintDialog question

查看:206
本文介绍了PrintDialog问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PrintDialog,它将允许用户选择页面范围,副本,整理和页面方向.

I'm using a PrintDialog that will allow users to select page ranges, copies, collating and page orientation. 

我的问题是,如果纵向页面数少于横向页面数,我该如何处理页面范围?

My question is how do i work with page ranges if the portrait page count is less than the landscape page count?

我不想允许用户选择无效的页面范围,并且我想确保提供正确数量的页面供您选择...

I don't want to allow users to select an invalid page range, and i want to be sure to offer the correct number of pages to choose from...

感谢您的帮助

推荐答案

嗨.paul,

Hi .paul,

看起来您需要使用QueryPageSettings来将每个页面设置为某种内容.

Looks like you need to use QueryPageSettings to set each page to something.

此示例显示了设置风景.那么,您可以通过这种方式定义每个页面的需求吗?我不确定您对页面范围"的处理方式或如何确定它们?

This example shows setting landscape. So can you define what you need for each page this way somehow? I am not sure what you are doing with "page ranges" or how you determine them?

也许您可以创建一个类并携带每个页面的属性,然后在QueryPageSettings中进行类似的设置?

Maybe you can make a class and carry properties for each page and set them in the QueryPageSettings similar to this?

Option Strict On
Imports System.Drawing.Printing

Public Class Form7
    Private MyPageCount As Integer
    Private WithEvents pd As New System.Drawing.Printing.PrintDocument

    Private Sub Form7_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        
        Dim printPreview As New PrintPreviewDialog()

        MyPageCount = 2

        printPreview.Document = pd
        printPreview.ShowDialog()

    End Sub

    Private Sub pd_QueryPageSettings(sender As Object, e As QueryPageSettingsEventArgs) Handles pd.QueryPageSettings
        If MyPageCount = 1 Then
            e.PageSettings.Landscape = True
        Else
            e.PageSettings.Landscape = False
        End If

    End Sub

    Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage

        e.Graphics.DrawString("Page " & MyPageCount.ToString, Font,
                              Brushes.Black, e.MarginBounds.X, e.MarginBounds.Y)

        MyPageCount -= 1
        If MyPageCount > 0 Then
            e.HasMorePages = True
        Else
            e.HasMorePages = False
            MyPageCount = 2
        End If

    End Sub
End Class


这篇关于PrintDialog问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆