PrintSystemObject.PropertiesCollection 屬性

定義

取得屬性和值組的集合。

public:
 property System::Printing::IndexedProperties::PrintPropertyDictionary ^ PropertiesCollection { System::Printing::IndexedProperties::PrintPropertyDictionary ^ get(); };
public System.Printing.IndexedProperties.PrintPropertyDictionary PropertiesCollection { get; }
member this.PropertiesCollection : System.Printing.IndexedProperties.PrintPropertyDictionary
Public ReadOnly Property PropertiesCollection As PrintPropertyDictionary

屬性值

PrintPropertyDictionary,包含屬性和值組。

範例

下列範例示範如何使用這個屬性在執行時間探索屬性,以及列印系統物件的這些屬性類型,而不使用反映。


// Enumerate the properties, and their types, of a queue without using Reflection
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();

PrintPropertyDictionary printQueueProperties = defaultPrintQueue.PropertiesCollection;

Console.WriteLine("These are the properties, and their types, of {0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() +"\n");

foreach (DictionaryEntry entry in printQueueProperties)
{
    PrintProperty property = (PrintProperty)entry.Value;

    if (property.Value != null)
    {
        Console.WriteLine(property.Name + "\t(Type: {0})", property.Value.GetType().ToString());
    }
}
Console.WriteLine("\n\nPress Return to continue...");
Console.ReadLine();

' Enumerate the properties, and their types, of a queue without using Reflection
Dim localPrintServer As New LocalPrintServer()
Dim defaultPrintQueue As PrintQueue = LocalPrintServer.GetDefaultPrintQueue()

Dim printQueueProperties As PrintPropertyDictionary = defaultPrintQueue.PropertiesCollection

Console.WriteLine("These are the properties, and their types, of {0}, a {1}", defaultPrintQueue.Name, defaultPrintQueue.GetType().ToString() + vbLf)

For Each entry As DictionaryEntry In printQueueProperties
    Dim [property] As PrintProperty = CType(entry.Value, PrintProperty)

    If [property].Value IsNot Nothing Then
        Console.WriteLine([property].Name & vbTab & "(Type: {0})", [property].Value.GetType().ToString())
    End If
Next entry
Console.WriteLine(vbLf & vbLf & "Press Return to continue...")
Console.ReadLine()

適用於