将表单的控件动态复制到面板中 [英] copy controls of a form into a panel dynamically

查看:105
本文介绍了将表单的控件动态复制到面板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我现在正在开发一个Windows项目。我已经设计并编写了几乎所有程序。并且一个想法只是让我头疼。但我无法想出任何可行的方法。请帮我解决这个问题。



第一个项目:

我有一个带按钮控件的表格。如果我按下每个按钮,其他表格将显示为

* .ShowDialog()。我刚刚以旧时尚的方式完成。



新想法:



我刚做了父母表格更大一点。我在那里放了一个面板。



现在我按下那个按钮时,我需要* .ShowDialog()中的控件,事件和其他内容出现在我的面板中。



即:我只需要将整个表单动态转移到面板中并执行功能和事件。



等待你的好意。



Irshad

Hi Friends,
I am working on a windows project right now on my own.I had designed and coded almost of the program.And an Idea just strike my head. But I cant figure any possible ways to do it. Please help me in this matter.

First Project:
I have a form with button controls. And if I press each button another forms will appear as
" *.ShowDialog() ". I just done it in old fashion way.

New Idea :

I just made my parent form a little bit bigger. And I placed a panel there.

Now I need the controls, events and whatever in " *.ShowDialog() " to appear in my panel when I press that button.

That is: I just need to transfer whole form into a panel dynamically and execute the functions and events .

Waiting for your kindness.

Irshad

推荐答案

我不会这样做那样。

相反,我会创建一个控件集合作为UserControl,并在表单或面板中包含其中一个。它更容易做,而且更易于管理。
I wouldn''t do it that way.
Instead, I would create the collection of controls as a UserControl, and include one of those in the form, or in the panel instead. It''s easier to do, and an lot more manageable.


这篇关于将表单的控件动态复制到面板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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