如何在运行时在Windows窗体中添加控件? [英] How to add a control in windows forms at runtime?

查看:74
本文介绍了如何在运行时在Windows窗体中添加控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的C#团队,

我的Windows窗体中包含一个国家的省列表,我有一个复选框列表,我想启用此窗体的最终用户,可以在运行时将其添加并保存到我的省复选框列表中.部署此应用程序后,有时会在该国家/地区添加新的省.

Dear C# Team,

I have a check box list in my windows form containing provinces list of a country, I would like to enable the end user of this form that can add and save it to my province check box list at run time. When this application deployed, sometime if a new province added to the country.

推荐答案

动态添加控件如下所示

创建控件的新实例

Button b = new Button();

然后,您所需要做的就是设置位置和所需的其他属性.对于该按钮.
Dynamically Adding Controls is as follows

Create a new instance of the control

Button b = new Button();

Then all you need to do is set the location and the rest of the properties you want. For that button.


这篇关于如何在运行时在Windows窗体中添加控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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