Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft einen Wert ab, der angibt, ob die Seite in Farbe gedruckt werden soll, oder legt diesen fest.
Namespace: System.Drawing.Printing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Property Color As Boolean
'Usage
Dim instance As PageSettings
Dim value As Boolean
value = instance.Color
instance.Color = value
public bool Color { get; set; }
public:
property bool Color {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_Color ()
/** @property */
public void set_Color (boolean value)
public function get Color () : boolean
public function set Color (value : boolean)
Eigenschaftenwert
true, wenn die Seite in Farbe gedruckt werden soll, andernfalls false. Der Standardwert wird durch den Drucker bestimmt.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der in der PrinterSettings.PrinterName-Eigenschaft bezeichnete Drucker ist nicht vorhanden. |
Hinweise
Mithilfe der PrinterSettings.SupportsColor-Eigenschaft können Sie bestimmen, ob der Drucker Farbdruck unterstützt. Wenn der Drucker Farbdruck unterstützt und Sie nicht in Farbe drucken möchten, legen Sie die Color-Eigenschaft auf false fest. Der Standardwert ist true.
Beispiel
Im folgenden Codebeispiel wird ein Dokument gedruckt, wobei die erste Seite in Farbe gedruckt wird, sofern der Drucker dies unterstützt. Bei diesem Beispiel muss zuvor die PrintDocument-Variable printDoc erstellt werden. Außerdem müssen das PrintPage-Ereignis und das QueryPageSettings-Ereignis behandelt werden.
Verwenden Sie für dieses Beispiel den System.Drawing-Namespace und den System.Drawing.Printing-Namespace.
Private Sub MyButtonPrint_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
' Set the printer name and ensure it is valid. If not, provide a message to the user.
printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter"
If printDoc.PrinterSettings.IsValid Then
' If the printer supports printing in color, then override the printer's default behavior.
if printDoc.PrinterSettings.SupportsColor then
' Set the page default's to not print in color.
printDoc.DefaultPageSettings.Color = False
End If
' Provide a friendly name, set the page number, and print the document.
printDoc.DocumentName = "My Presentation"
currentPageNumber = 1
printDoc.Print()
Else
MessageBox.Show("Printer is not valid")
End If
End Sub
Private Sub MyPrintQueryPageSettingsEvent(ByVal sender As Object, ByVal e As QueryPageSettingsEventArgs)
' Determines if the printer supports printing in color.
If printDoc.PrinterSettings.SupportsColor Then
' If the printer supports color printing, use color.
If currentPageNumber = 1 Then
e.PageSettings.Color = True
End If
End If
End Sub
private void MyButtonPrint_OnClick(object sender, System.EventArgs e)
{
// Set the printer name and ensure it is valid. If not, provide a message to the user.
printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter";
if (printDoc.PrinterSettings.IsValid) {
// If the printer supports printing in color, then override the printer's default behavior.
if (printDoc.PrinterSettings.SupportsColor) {
// Set the page default's to not print in color.
printDoc.DefaultPageSettings.Color = false;
}
// Provide a friendly name, set the page number, and print the document.
printDoc.DocumentName = "My Presentation";
currentPageNumber = 1;
printDoc.Print();
}
else {
MessageBox.Show("Printer is not valid");
}
}
private void MyPrintQueryPageSettingsEvent(object sender, QueryPageSettingsEventArgs e)
{
// Determines if the printer supports printing in color.
if (printDoc.PrinterSettings.SupportsColor) {
// If the printer supports color printing, use color.
if (currentPageNumber == 1 ) {
e.PageSettings.Color = true;
}
}
}
private:
void MyButtonPrint_OnClick( Object^ sender, System::EventArgs^ e )
{
// Set the printer name and ensure it is valid. If not, provide a message to the user.
printDoc->PrinterSettings->PrinterName = "\\mynetworkprinter";
if ( printDoc->PrinterSettings->IsValid )
{
// If the printer supports printing in color, then override the printer's default behavior.
if ( printDoc->PrinterSettings->SupportsColor )
{
// Set the page default's to not print in color.
printDoc->DefaultPageSettings->Color = false;
}
// Provide a friendly name, set the page number, and print the document.
printDoc->DocumentName = "My Presentation";
currentPageNumber = 1;
printDoc->Print();
}
else
{
MessageBox::Show( "Printer is not valid" );
}
}
void MyPrintQueryPageSettingsEvent( Object^ sender, QueryPageSettingsEventArgs^ e )
{
// Determines if the printer supports printing in color.
if ( printDoc->PrinterSettings->SupportsColor )
{
// If the printer supports color printing, use color.
if ( currentPageNumber == 1 )
{
e->PageSettings->Color = true;
}
}
}
private void myButtonPrint_OnClick(Object sender, System.EventArgs e)
{
// Set the printer name and ensure it is valid. If not,
// provide a message to the user.
printDoc.get_PrinterSettings().set_PrinterName("\\mynetworkprinter");
if (printDoc.get_PrinterSettings().get_IsValid()) {
// If the printer supports printing in color, then
// override the printer's default behavior.
if (printDoc.get_PrinterSettings().get_SupportsColor()) {
// Set the page default's to not print in color.
printDoc.get_DefaultPageSettings().set_Color(false);
}
// Provide a friendly name, set the page number, and print
// the document.
printDoc.set_DocumentName("My Presentation");
currentPageNumber = 1;
printDoc.Print();
}
else {
MessageBox.Show("Printer is not valid");
}
} //myButtonPrint_OnClick
private void MyPrintQueryPageSettingsEvent(Object sender,
QueryPageSettingsEventArgs e)
{
// Determines if the printer supports printing in color.
if (printDoc.get_PrinterSettings().get_SupportsColor()) {
// If the printer supports color printing, use color.
if (currentPageNumber == 1) {
e.get_PageSettings().set_Color(true);
}
}
} //MyPrintQueryPageSettingsEvent
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
PageSettings-Klasse
PageSettings-Member
System.Drawing.Printing-Namespace
PrinterSettings.SupportsColor