PrinterCollection 類別
提供印表機的集合,以供升級的 Visual Basic 6.0 列印程式碼使用。
繼承階層架構
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 實作有顯著差異時,才需要這些項目。 |
範例
下列範例示範如何傳回印表機清單。 它假設您有一份表單,其中一個 ListBox 控制項的具名 ListBox1。
Dim i As Integer
For i = 0 To Printers.Count - 1
ListBox1.Items.Add(Printers(i).DeviceName)
Next
執行緒安全
這個類型的任何 Public static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員是安全執行緒。
請參閱
參考
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 命名空間
其他資源
How to: Fix Upgrade Errors by Using the Printer Compatibility Library (Visual Basic)
Deploying Applications That Reference the Printer Compatibility Library