Skip to content

Tip: To reuse a Webview2 Control from a previously closed window in VB.Net #3810

Description

@dacurrey

To reuse a Webview2 control from a previously closed window. (VB.NET Code)

  1. Ensure that the Webview2 control in Form2 was initialized from the Form_Main
  2. Call Form2 with a check to see if re-initialization is required
Private Sub Form_Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
     Form2.Webview_Form2.Source = New Uri("about:blank")
End Sub

Private Sub OpenForm2()
     if PreviouslyLoaded = True Then ReinitializeWebView_Form2()
     Form2.WebView_Form2.Source = New Uri("https://www.google.com/")
     PreviouslyLoaded = True
     Form2.Show()
End Sub

Private Async Sub ReinitializeWebView_Form2()
    Await Form2.WebView_Form2.EnsureCoreWebView2Async()
End Sub

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions