vb.net 向窗体添加用户控件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13280150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:03:59 来源:igfitidea点击:
add a user control to a form
提问by Renaud is Not Bill Gates
Hi there I have a user control in my project and I want to add this user control to a form when I click on a button.
嗨,我的项目中有一个用户控件,我想在单击按钮时将此用户控件添加到表单中。
This is the code I wrote:
这是我写的代码:
Using GstAbonnement As New GestionAbonnement() With {.Dock = DockStyle.Fill}
Panel1.Controls.Add(GstAbonnement)
End Using
The problem is when I click on the button nothing happens
问题是当我点击按钮时什么也没有发生
回答by Sylens
try this
尝试这个
Dim GstAbonnement As New GestionAbonnement()
GstAbonnement.Dock = DockStyle.Fill
Panel1.Controls.Add(GstAbonnement)
After you are done with the control, dispose it
完成控制后,处置它
GstAbonnement.Dispose()

