PageSettings 类

定义

指定应用于单页打印的设置。

public ref class PageSettings : ICloneable
public class PageSettings : ICloneable
[System.Runtime.InteropServices.ComVisible(false)]
public class PageSettings : ICloneable
[System.Serializable]
public class PageSettings : ICloneable
type PageSettings = class
    interface ICloneable
[<System.Runtime.InteropServices.ComVisible(false)>]
type PageSettings = class
    interface ICloneable
[<System.Serializable>]
type PageSettings = class
    interface ICloneable
Public Class PageSettings
Implements ICloneable
继承
PageSettings
属性
实现

示例

下面的示例演示如何处理 PrintPage 事件并检查 PageSettingsPrintPageEventArgs参数。 若要使用此代码,请将名为 的组件添加到 PrintDocument Windows 窗体,并将其PrintPage事件与printDocument1_PrintPage示例中的 方法PrintDocument1相关联。

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    if (e.PageSettings.Color && !printDocument1.PrinterSettings.SupportsColor)
        MessageBox.Show("Color printing not supported on selected printer.", "Printer Warning", MessageBoxButtons.OKCancel);
}
Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)  Handles printDocument1.PrintPage
    If e.PageSettings.Color AndAlso Not printDocument1.PrinterSettings.SupportsColor Then
        MessageBox.Show("Color printing not supported on selected printer.", "Printer Warning", MessageBoxButtons.OKCancel)
    End If

End Sub

注解

PageSettings 用于指定修改页面打印方式的设置。 通常,为要通过 PrintDocument.DefaultPageSettings 属性打印的所有页面设置默认设置。 若要逐页指定设置,请分别处理 PrintDocument.PrintPagePrintDocument.QueryPageSettings 事件并修改 PageSettingsQueryPageSettingsEventArgs中包含的PrintPageEventArgs参数。

有关处理 PrintDocument 事件的详细信息,请参阅 PrintDocument 类概述。 有关打印的详细信息,请参阅 System.Drawing.Printing 命名空间概述。

备注

在 .NET 6 及更高版本中, System.Drawing.Common 包(包括此类型)仅在 Windows 操作系统上受支持。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 System.Drawing.Common 仅在 Windows 上受支持

构造函数

PageSettings()

使用默认打印机初始化 PageSettings 类的新实例。

PageSettings(PrinterSettings)

使用指定打印机初始化 PageSettings 类的新实例。

属性

Bounds

获取页面的大小,并且考虑由 Landscape 属性指定的页面方向。

Color

获取或设置一个值,该值指示是否应以彩色打印该页。

HardMarginX

获取页面左侧硬页边距的 X 坐标(以百分之一英寸为单位)。

HardMarginY

获取页面上方硬页边距的 Y 坐标(以百分之一英寸为单位)。

Landscape

获取或设置一个值,该值指示是横向还是纵向打印该页。

Margins

获取或设置该页的边距。

PaperSize

获取或设置该页的纸张大小。

PaperSource

获取或设置该页的纸张来源;例如打印机的上层纸盒。

PrintableArea

获取打印机的可打印页面区域的界限。

PrinterResolution

获取或设置该页的打印机分辨率。

PrinterSettings

获取或设置与该页关联的打印机设置。

方法

Clone()

创建此 PageSettings 的副本。

CopyToHdevmode(IntPtr)

将相关信息从 PageSettings 复制到指定的 DEVMODE 结构。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
SetHdevmode(IntPtr)

将相关信息从指定的 DEVMODE 结构复制到 PageSettings

ToString()

PageSettings 转换为字符串形式。

适用于

另请参阅