VB.NET一个控件同时放入两个容器
PublicClassForm1PrivateWebAsNewWebBrowserPrivateSubForm1_Load(ByValsenderAsSystem.Obj...
Public Class Form1
Private Web As New WebBrowser
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Web.Navigate("我是网址")
Web.Dock = DockStyle.Fill
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Panel1.Controls.Add(Web)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Panel2.Controls.Add(Web)
End Sub
End Class
如上代码,按按钮1时WebBrowser控件在Panel1中出现,按按钮2时WebBrowser控件在Panel2中出现,但是Panel1中的WebBrowser消失了,从效果上来说实现了我需要的目的,我想问的是这样操作会出现错误吗?导致程序崩溃或者内存占用之类的 展开
Private Web As New WebBrowser
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Web.Navigate("我是网址")
Web.Dock = DockStyle.Fill
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Panel1.Controls.Add(Web)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Panel2.Controls.Add(Web)
End Sub
End Class
如上代码,按按钮1时WebBrowser控件在Panel1中出现,按按钮2时WebBrowser控件在Panel2中出现,但是Panel1中的WebBrowser消失了,从效果上来说实现了我需要的目的,我想问的是这样操作会出现错误吗?导致程序崩溃或者内存占用之类的 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询