PrinterSettings.PaperSourceCollection 类

包含 PaperSource 对象的集合。

**命名空间:**System.Drawing.Printing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Class PaperSourceCollection
    Implements ICollection, IEnumerable
用法
Dim instance As PaperSourceCollection
public class PaperSourceCollection : ICollection, IEnumerable
public ref class PaperSourceCollection : ICollection, IEnumerable
public class PaperSourceCollection implements ICollection, IEnumerable
public class PaperSourceCollection implements ICollection, IEnumerable

备注

PrinterSettings.PaperSourceCollection 包含 PaperSource 实例,该实例通过 PaperSource.Kind 属性(它包含 PaperSourceKind 值之一)表示纸张来源纸盒。

通常可以通过 PageSettings.PaperSource 属性将页的纸张来源设置为有效的 PaperSource 实例(可通过 PaperSources 集合获得)。

示例

下面的代码示例用打印机支持的纸张来源填充 comboPaperSource 组合框。SourceName 被标识为向通过组合框的 DisplayMember 属性添加的项提供显示字符串的属性。该示例要求名为 printDocPrintDocument 变量和特定的组合框都已存在。

' Add list of paper sources found on the printer to the combo box.
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSource.DisplayMember = "SourceName"

Dim pkSource As PaperSource
For i = 0 to printDoc.PrinterSettings.PaperSources.Count - 1
    pkSource = printDoc.PrinterSettings.PaperSources.Item(i)
    comboPaperSource.Items.Add(pkSource)
Next
// Add list of paper sources found on the printer to the combo box.
// The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSource.DisplayMember="SourceName";

PaperSource pkSource;
for (int i = 0; i < printDoc.PrinterSettings.PaperSources.Count; i++){
    pkSource = printDoc.PrinterSettings.PaperSources[i];
    comboPaperSource.Items.Add(pkSource);
}
// Add list of paper sources found on the printer to the combo box.
// The DisplayMember property is used to identify the property that will provide the display String*.
comboPaperSource->DisplayMember = "SourceName";
PaperSource^ pkSource;
for ( int i = 0; i < printDoc->PrinterSettings->PaperSources->Count; i++ )
{
   pkSource = printDoc->PrinterSettings->PaperSources[ i ];
   comboPaperSource->Items->Add( pkSource );
}
// Add list of paper sources found on the printer to the combo box.
// The DisplayMember property is used to identify the property that
// will provide the display string.
comboPaperSource.set_DisplayMember("SourceName");

PaperSource pkSource;
for (int i = 0; i < printDoc.get_PrinterSettings().get_PaperSources().
    get_Count(); i++) {
    pkSource = printDoc.get_PrinterSettings().get_PaperSources().
        get_Item(i);
    comboPaperSource.get_Items().Add(pkSource);
}

继承层次结构

System.Object
  System.Drawing.Printing.PrinterSettings.PaperSourceCollection

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PrinterSettings.PaperSourceCollection 成员
System.Drawing.Printing 命名空间
PaperSource 类
PrinterSettings.PaperSources 属性
PrinterSettings.InstalledPrinters 属性
PrinterSettings.PaperSizes 属性
PrinterSettings.PrinterResolutions 属性
ListControl.DisplayMember