PrintStringProperty Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Représente une String propriété (et sa valeur) d’un composant matériel ou logiciel du système d’impression.
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
- Héritage
- Attributs
Exemples
L’exemple suivant montre comment utiliser cette classe pour installer une deuxième imprimante qui diffère de ses propriétés d’une imprimante existante uniquement à l’emplacement, au port et à l’état partagé.
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()
Constructeurs
| Nom | Description |
|---|---|
| PrintStringProperty(String, Object) |
Initialise une nouvelle instance de la PrintStringProperty classe qui a la valeur spécifiée pour la propriété spécifiée. |
| PrintStringProperty(String) |
Initialise une nouvelle instance de la PrintStringProperty classe pour la propriété spécifiée. |
Propriétés
| Nom | Description |
|---|---|
| IsDisposed |
Obtient ou définit une valeur qui indique si l’objet a été supprimé. (Hérité de PrintProperty) |
| IsInitialized |
Obtient ou définit une valeur qui indique si l’objet a été initialisé. (Hérité de PrintProperty) |
| Name |
En cas de substitution dans une classe dérivée, obtient le nom de la propriété que l’objet représente. (Hérité de PrintProperty) |
| Value |
Obtient ou définit la valeur de la propriété que représente PrintStringProperty . |
Méthodes
| Nom | Description |
|---|---|
| Dispose() |
Libère toutes les ressources utilisées par le PrintProperty. (Hérité de PrintProperty) |
| Dispose(Boolean) |
Libère les ressources non managées utilisées par les PrintProperty ressources gérées et les libère éventuellement. (Hérité de PrintProperty) |
| Equals(Object) |
Détermine si l’objet spécifié est égal à l’objet actuel. (Hérité de Object) |
| GetHashCode() |
Sert de fonction de hachage par défaut. (Hérité de Object) |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| InternalDispose(Boolean) |
Libère les ressources non managées utilisées par les PrintProperty ressources gérées et les libère éventuellement. (Hérité de PrintProperty) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| OnDeserialization(Object) |
En cas de substitution dans une classe dérivée, implémente l’interface ISerializable et déclenche l’événement de désérialisation lorsque la désérialisation est terminée. (Hérité de PrintProperty) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
Opérateurs
| Nom | Description |
|---|---|
| Implicit(PrintStringProperty to String) |
Fournit une conversion implicite en valeur d’un String pointeur vers un PrintStringProperty. |