将面板复制到在运行时创建的另一个面板

将面板复制到在运行时创建的另一个面板

本文介绍了将面板复制到在运行时创建的另一个面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我试图将一个面板复制到在运行时创建的另一个面板,但是旧面板不断消失,您能告诉我什么地方出问题吗?

我的代码:

Hey,

I'' trying to copy one panel into another panel which is created at run time but the old panel keeps disappearing , can you tell me what''s wrong ?

my code :

Friend withevent NewPanel As New Panel
Me.Controls.Add(NewPanel)
NewPanel = Panel1
NewPanel.Top=Panel1.Top + Panel1.Height 

推荐答案

NewPanel.Left = Panel1.Left
NewPanel.Top = Panel1.Top



添加与配置旧面板一样需要配置新面板的所有属性.

然后,您需要对面板中的所有控件执行类似的操作.

实话实说,这是很多艰苦的工作.我将创建一个自定义控件,其中包含一个面板以及该面板中包含的所有控件.然后,您只需要创建自定义控件的新实例.

以下是开发自定义控件的介绍.

http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx [ ^ ]



Adding all the properties you need to configure the new panel as the old one was.

You then need to do a similar thing for the all the controls within the panel.

Truth be told, that''s a lot of hard work. I''d create a custom control which contains a Panel and all the controls contained within the Panel. Then you need only create a new instance of your custom control.

The following is an introduction to developing custom controls.

http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx[^]


这篇关于将面板复制到在运行时创建的另一个面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 18:29