PrinterSettings.SupportsColor 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,指出這個印表機是否支援彩色列印。
public:
property bool SupportsColor { bool get(); };
public bool SupportsColor { get; }
member this.SupportsColor : bool
Public ReadOnly Property SupportsColor As Boolean
屬性值
如果印表機支援彩色列印,則為 true
,否則為 false
。
範例
如果印表機支援檔,下列程式代碼範例會以色彩列印具有第一頁的檔。 此範例會要求 PrintDocument 已建立名為 printDoc
的變數,而且 PrintPage 會處理 和 QueryPageSettings 事件。
使用此範例的 System.Drawing 和 System.Drawing.Printing 命名空間。
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.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 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
備註
若要使用色彩列印,而且印表機支援它,請將 設定 PageSettings.Color 為 true
。