vb.net 怎么实现一个列表可以在多个窗体上使用
1个回答
展开全部
给你个例子
新建两个窗体Form1,Form2,每个窗体上放置一个按钮Button1,在Form1上放置ListBox1控件
Form1的Button1的代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As Control
For Each c In Controls
If c.Name.Equals("ListBox1") Then
c.Parent = Form2
Form2.Show()
End If
Next
End Sub
Form2的Button1的代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As Control
For Each c In Controls
If c.Name.Equals("ListBox1") Then
c.Parent = Form1
Form1.Show()
End If
Next
End Sub
运行界面如下
点击Button1,ListBox1控件,会在两个窗体间移动
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询