WebBrowser.DocumentCompleted 이벤트

정의

WebBrowser 컨트롤이 문서 로드를 완료할 때 발생합니다.

public:
 event System::Windows::Forms::WebBrowserDocumentCompletedEventHandler ^ DocumentCompleted;
public event System.Windows.Forms.WebBrowserDocumentCompletedEventHandler DocumentCompleted;
public event System.Windows.Forms.WebBrowserDocumentCompletedEventHandler? DocumentCompleted;
member this.DocumentCompleted : System.Windows.Forms.WebBrowserDocumentCompletedEventHandler 
Public Custom Event DocumentCompleted As WebBrowserDocumentCompletedEventHandler 
Public Event DocumentCompleted As WebBrowserDocumentCompletedEventHandler 

이벤트 유형

예제

다음 코드 예제에서는 이 이벤트를 사용하여 문서가 완전히 로드된 후 인쇄하는 방법을 보여 줍니다.

private void PrintHelpPage()
{
    // Create a WebBrowser instance. 
    WebBrowser webBrowserForPrinting = new WebBrowser();

    // Add an event handler that prints the document after it loads.
    webBrowserForPrinting.DocumentCompleted +=
        new WebBrowserDocumentCompletedEventHandler(PrintDocument);

    // Set the Url property to load the document.
    webBrowserForPrinting.Url = new Uri(@"\\myshare\help.html");
}

private void PrintDocument(object sender,
    WebBrowserDocumentCompletedEventArgs e)
{
    // Print the document now that it is fully loaded.
    ((WebBrowser)sender).Print();

    // Dispose the WebBrowser now that the task is complete. 
    ((WebBrowser)sender).Dispose();
}
Private Sub PrintHelpPage()

    ' Create a WebBrowser instance. 
    Dim webBrowserForPrinting As New WebBrowser()

    ' Add an event handler that prints the document after it loads.
    AddHandler webBrowserForPrinting.DocumentCompleted, New _
        WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument)

    ' Set the Url property to load the document.
    webBrowserForPrinting.Url = New Uri("\\myshare\help.html")

End Sub

Private Sub PrintDocument(ByVal sender As Object, _
    ByVal e As WebBrowserDocumentCompletedEventArgs)

    Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)

    ' Print the document now that it is fully loaded.
    webBrowserForPrinting.Print()
    MessageBox.Show("print")

    ' Dispose the WebBrowser now that the task is complete. 
    webBrowserForPrinting.Dispose()

End Sub

설명

WebBrowser 컨트롤 집합은 다음 속성 중 하나 또는 메서드가 호출 될 때마다 새 문서를 탐색 합니다.

처리는 DocumentCompleted 이벤트를 새 문서에서 로드가 완료 되 면 알림을 받습니다. 경우는 DocumentCompleted 이벤트가 발생 하면 새 문서는 완전히 로드 즉, 해당 콘텐츠를 통해 액세스할 수 있습니다 합니다 Document, DocumentText, 또는 DocumentStream 속성입니다.

탐색이 시작되기 전에 알림을 받으려면 이벤트를 처리합니다 Navigating . 이 이벤트를 처리 하는 사용자가 폼을 완전히 작성 하지 않은 것 예를 들어, 특정 조건이 충족 되지 않은 경우 탐색을 취소할 수 있습니다. 처리를 Navigated 이벤트 알림을 받을 때의 WebBrowser 컨트롤 탐색을 완료 하 고 새 위치에 문서 로드를 시작한 합니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보