vb.net 怎么实现一个列表可以在多个窗体上使用
答案:1 悬赏:0 手机版
解决时间 2021-11-10 04:37
- 提问者网友:ミ烙印ゝ
- 2021-11-09 15:44
vb.net 怎么实现一个列表可以在多个窗体上使用
最佳答案
- 五星知识达人网友:有你哪都是故乡
- 2021-11-09 15:58
给你个例子
新建两个窗体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 SubForm2的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控件,会在两个窗体间移动
新建两个窗体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 SubForm2的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控件,会在两个窗体间移动
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯