Share via


PrinterCollection Class

Provides a collection of printers for use by upgraded Visual Basic 6.0 printing code.

Inheritance Hierarchy

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

Namespace:  Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
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

The PrinterCollection type exposes the following members.

Constructors

  Name Description
Public method PrinterCollection Initializes a PrinterCollection object.

Top

Properties

  Name Description
Public property Count Returns the number of printers in the Printers collection.
Public property Item Returns a specific member of the Printers collection by index number.

Top

Methods

  Name Description
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IEnumerable.GetEnumerator

Top

Remarks

The PrinterCollection class exposes a global Printers collection that returns a collection of available printers on the system.

The Printers collection uses a zero-based index: the first Printer has an Index of 0, the second has an Index of 1, and so on.

The Printers collection is read-only; you cannot add or remove a Printer object from Printers.

Note

Functions and objects in the Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic 2010. In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.

Examples

The following example demonstrates how to return a list of printers. It assumes that you have a ListBox control named ListBox1.

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Namespace

Other Resources

Printer Compatibility Library

How to: Fix Upgrade Errors by Using the Printer Compatibility Library (Visual Basic)

Deploying Applications That Reference the Printer Compatibility Library