WebBrowser.Print 方法

定義

使用目前的列印與頁面設定,列印目前控制件中 WebBrowser 顯示的文件。

public:
 void Print();
public void Print();
member this.Print : unit -> unit
Public Sub Print ()

範例

以下程式碼範例示範如何使用 Print 方法實作一個 Print 按鈕,該按鈕與 Internet Explorer 中的 WebBrowser 控制點相似。 這個範例要求你的形式包含WebBrowser一個名為 webBrowser1 的控制項和Button一個名為 的控制項。ButtonPrint

// Prints the current document using the current print settings.
void ButtonPrint_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   this->WebBrowser1->Print();
}
// Prints the current document using the current print settings.
private void printButton_Click(object sender, EventArgs e)
{
    webBrowser1.Print();
}
' Prints the current document Imports the current print settings.
Private Sub printButton_Click( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles printButton.Click

    webBrowser1.Print()

End Sub

備註

你可以用這個方法實作一個類似 Internet Explorer 裡的 Print 按鈕。 此方法可列印目前的文件,無需使用者進一步輸入。 若要在列印前顯示 列印 對話框,請使用此 ShowPrintDialog 方法。 要顯示頁面 設定 對話框,讓使用者能指定頁首和頁尾值及其他頁面設定,請使用此 ShowPageSetupDialog 方法。 要顯示 列印預覽 對話框,請使用以下 ShowPrintPreviewDialog 方法。

適用於

另請參閱