PrintStringProperty 類別

定義

表示列印系統硬體或軟體元件的 String 屬性 (及其值)。

public ref class PrintStringProperty sealed : System::Printing::IndexedProperties::PrintProperty
[System.Serializable]
public sealed class PrintStringProperty : System.Printing.IndexedProperties.PrintProperty
public sealed class PrintStringProperty : System.Printing.IndexedProperties.PrintProperty
[<System.Serializable>]
type PrintStringProperty = class
    inherit PrintProperty
type PrintStringProperty = class
    inherit PrintProperty
Public NotInheritable Class PrintStringProperty
Inherits PrintProperty
繼承
PrintStringProperty
屬性

範例

下列範例示範如何使用這個類別來安裝第二部列印機,其屬性與現有印表機不同的位置、埠和共享狀態。

LocalPrintServer myLocalPrintServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue sourcePrintQueue = myLocalPrintServer.DefaultPrintQueue;
PrintPropertyDictionary myPrintProperties = sourcePrintQueue.PropertiesCollection;

// Share the new printer using Remove/Add methods
PrintBooleanProperty shared = new PrintBooleanProperty("IsShared", true);
myPrintProperties.Remove("IsShared");
myPrintProperties.Add("IsShared", shared);

// Give the new printer its share name using SetProperty method
PrintStringProperty theShareName = new PrintStringProperty("ShareName", "\"Son of " + sourcePrintQueue.Name +"\"");
myPrintProperties.SetProperty("ShareName", theShareName);

// Specify the physical location of the new printer using Remove/Add methods
PrintStringProperty theLocation = new PrintStringProperty("Location", "the supply room");
myPrintProperties.Remove("Location");
myPrintProperties.Add("Location", theLocation);

// Specify the port for the new printer
String[] port = new String[] { "COM1:" };

// Install the new printer on the local print server
PrintQueue clonedPrinter = myLocalPrintServer.InstallPrintQueue("My clone of " + sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties);
myLocalPrintServer.Commit();

// Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName);
Console.WriteLine("Press Return to continue ...");
Console.ReadLine();
Dim myLocalPrintServer As New LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer)
Dim sourcePrintQueue As PrintQueue = myLocalPrintServer.DefaultPrintQueue
Dim myPrintProperties As PrintPropertyDictionary = sourcePrintQueue.PropertiesCollection

' Share the new printer using Remove/Add methods
Dim [shared] As New PrintBooleanProperty("IsShared", True)
myPrintProperties.Remove("IsShared")
myPrintProperties.Add("IsShared", [shared])

' Give the new printer its share name using SetProperty method
Dim theShareName As New PrintStringProperty("ShareName", """Son of " & sourcePrintQueue.Name & """")
myPrintProperties.SetProperty("ShareName", theShareName)

' Specify the physical location of the new printer using Remove/Add methods
Dim theLocation As New PrintStringProperty("Location", "the supply room")
myPrintProperties.Remove("Location")
myPrintProperties.Add("Location", theLocation)

' Specify the port for the new printer
Dim port() As String = { "COM1:" }


' Install the new printer on the local print server
Dim clonedPrinter As PrintQueue = myLocalPrintServer.InstallPrintQueue("My clone of " & sourcePrintQueue.Name, "Xerox WCP 35 PS", port, "WinPrint", myPrintProperties)
myLocalPrintServer.Commit()

' Report outcome
Console.WriteLine("{0} in {1} has been installed and shared as {2}", clonedPrinter.Name, clonedPrinter.Location, clonedPrinter.ShareName)
Console.WriteLine("Press Return to continue ...")
Console.ReadLine()

建構函式

PrintStringProperty(String)

初始化所指定之屬性之 PrintStringProperty 類別的新執行個體。

PrintStringProperty(String, Object)

初始化指定屬性擁有指定值之 PrintStringProperty 類別的新執行個體。

屬性

IsDisposed

取得或設定一個值,指出是否已經處置物件。

(繼承來源 PrintProperty)
IsInitialized

取得或設定值,這個值表示物件是否已經初始化。

(繼承來源 PrintProperty)
Name

在衍生類別 (Derived Class) 中覆寫時,會取得物件所表示屬性的名稱。

(繼承來源 PrintProperty)
Value

取得或設定 PrintStringProperty 表示的屬性值。

方法

Dispose()

釋放 PrintProperty 正在使用的所有資源。

(繼承來源 PrintProperty)
Dispose(Boolean)

釋放 PrintProperty 正在使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 PrintProperty)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InternalDispose(Boolean)

釋放 PrintProperty 正在使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 PrintProperty)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnDeserialization(Object)

在衍生類別中覆寫時,如果還原序列化 (Deserialization) 完成,則實作 ISerializable 介面,並引發還原序列化事件。

(繼承來源 PrintProperty)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

運算子

Implicit(PrintStringProperty to String)

提供由指標的 String 值至 PrintStringProperty 的隱含轉換。

適用於