WebBrowser.Print 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用当前打印和页面设置打印控件中 WebBrowser 当前显示的文档。
public:
void Print();
public void Print();
member this.Print : unit -> unit
Public Sub Print ()
示例
下面的代码示例演示如何使用 Print 方法实现 Print 按钮的 WebBrowser 控件,该控件与Internet Explorer中的控件类似。 此示例要求窗体包含一个 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 该方法。