克隆Winform控件 [英] Clone Winform control

查看:800
本文介绍了克隆Winform控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB.NET winform应用程序中有一个groupox。组框包含几个标签,文本框和复选框。

I have a groupox in a VB.NET winform app. The groupbox contains a few Labels, Textboxes and Checkboxes. This was created by simply dragging the controls out of VS toolbox.

我需要做的是获取1 Groupbox,并在运行时根据用户选择创建多个Groupbox来显示。而不是动态创建嵌套在里面的Groupbox和其他控件,是否有克隆或复制原始控件的方法。

What I need to do is take the 1 Groupbox and at runtime create multiple Groupboxes to display based on user selection. Instead of dynamically creating the Groupboxes and other controls nested inside, is there a way to clone or copy the original one.

然后我只是更改属性。标签文本,文本框文本等。以及组框在布局中的位置。

Then I'd just change the properties. Label text, Textbox text, etc. And the location of the Groupbox in the layout.

推荐答案

基于您的分组框的用户控制,这将允许其重用。

What you could do is create a user control based upon your groupbox which would allow its reuse. You could then create the instances you require at runtime and add them to the form.

也许建议您尝试为winform创建用户控件。

Maybe suggest that you look into creating user controls for winforms.

这篇关于克隆Winform控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆