如何动态编码控件 [英] how to code the controls dynamically

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

问题描述

你好

我正在创建一个像应用程序这样的框架(例如,用于了解Visual Studio IDE,以便它本身具有设计和运行时间,这就是我们将使用控件来设计某些东西并运行所设计的东西)

因此,在运行时,我动态创建了一些.net控件,并将其添加到一个图纸视图[第三方]中,因此当我单击名为run的按钮时,必须在图纸视图上单独运行该设计好的东西,这就是我的应用程序运行时.我可以做到这一点吗?还有另一件事,如何在运行
之前对这些动态创建的控件进行编码?

问候

ginnas

hello

i am creating an framework like application [eg for understanding-visual studio IDE so that itself got design and run time that is we will design something by using controls and run that designed thing]

so in run time i dynamically created some .net controls and added in to one drawing view [third party] so when i click a button named run this designed thing on the drawing view has to run separately that is my applications run time.so how can i achieve this and one more thing how can i code these dynamically created controls before running


regards

ginnas

推荐答案

您必须创建一个控件并将其添加到容器的Controls集合中,例如Form,Panel,FlowLayoutPanel等.

例如:
Button btnSubmit = new Button();
btnSubmit.Text =提交";
this.Controls.Add(btnSubmit);

您还可以使用各自的属性指定Button的大小和位置
You have to create a control and add it to a container''s Controls collection like Form, Panel, FlowLayoutPanel etc.

Ex:
Button btnSubmit = new Button();
btnSubmit.Text = "Submit";
this.Controls.Add(btnSubmit);

You can also specify Button''s Size and Location using respective properties


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

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