从另一种形式调用暗淡

call a dim from another form

您好,我正在尝试从我的主窗体调用浏览器,但是当我输入 FrmWebBrowser.browser.

时它不可见

这是来自 FrmWebBrowser 的代码。

Imports CefSharp
Imports CefSharp.WinForms
Public Class FrmWebBrowser
    Public Sub FrmWebBrowser_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim settings As New CefSettings()
        Dim browser = New ChromiumWebBrowser("http://google.com/") With {
            .Dock = DockStyle.Fill
        }
        Me.Controls.Add(browser)
    End Sub
End Class

只需在表单开头声明 browser

dim browser as ChromiumWebBrowser
Public Sub FrmWebBrowser_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim settings As New CefSettings()
    browser = New ChromiumWebBrowser("http://google.com/") With {
        .Dock = DockStyle.Fill
    }
    Me.Controls.Add(browser)
End Sub