PrinterCollection 类

提供打印机的集合供打印代码的升级的 Visual Basic 6.0 使用。

继承层次结构

System.Object
  Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.PrinterCollection

命名空间:  Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
Public NotInheritable Class PrinterCollection _
    Implements IEnumerable
public sealed class PrinterCollection : IEnumerable
public ref class PrinterCollection sealed : IEnumerable
[<Sealed>]
type PrinterCollection =  
    class
        interface IEnumerable
    end
public final class PrinterCollection implements IEnumerable

PrinterCollection 类型公开以下成员。

构造函数

  名称 说明
公共方法 PrinterCollection 初始化 PrinterCollection 对象。

页首

属性

  名称 说明
公共属性 Count 返回打印机数。 Printers 集合。
公共属性 Item 按索引号返回 Printers 集合中的特定成员。

页首

方法

  名称 说明
公共方法 Equals 确定指定的对象是否等于当前对象。 (继承自 Object。)
公共方法 GetHashCode 用作特定类型的哈希函数。 (继承自 Object。)
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)

页首

显式接口实现

  名称 说明
显式接口实现私有方法 IEnumerable.GetEnumerator

页首

备注

PrinterCollection 类公开返回可用的打印机的集合在系统的全局 Printers 集合。

Printers 集合使用从零开始的索引:第一 Printer 具有 Index 0,第二个具有 Index 1,依此类推。

Printers 集合是只读的;不能从 Printers添加或移除 Printer 对象。

备注

Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 命名空间中的函数和对象是提供给用于将 Visual Basic 6.0 升级到 Visual Basic 的工具使用的。大多数情况下,这些函数和对象可再现 .NET Framework 中其他命名空间的功能。只有 Visual Basic 6.0 代码模型与 .NET Framework 实现有显著区别时才需要这些函数和对象。

示例

下面的示例演示如何返回打印机列表。 它,假设有一个名为 ListBox1的一个 ListBox 控件。

Dim i As Integer
For i = 0 To Printers.Count - 1
    ListBox1.Items.Add(Printers(i).DeviceName)
Next

线程安全

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

请参见

参考

Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 命名空间

其他资源

打印机兼容性库

如何:使用打印机兼容性库修复升级错误 (Visual Basic)

部署引用打印机兼容性库的应用程序