如何在C#Windows应用程序中使用用户控件 [英] How to use user control in c# windows applicatons

查看:108
本文介绍了如何在C#Windows应用程序中使用用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......
我正在开发C#Windows应用程序.在那,我创建了一个用户控件,它包含dropdownlist和textbox.在窗体中,当我在文本框中输入值2时(例如:Two),我希望两个用户控件应显示,即两个dropdownlist和两个textbox

Hi....
I am developing c# windows application. In that , i have created one user control, it contains dropdownlist and textbox.In the form when i enter value 2 in a textbox (Ex:Two) i want two user controls should display i.e two dropdownlist and two textbox

推荐答案



您需要在表单中动态添加用户控件.

如果您的表单中有一个面板,则可以使用以下方式添加用户控件:
Hi,

You need to dynamically add your user control in your Form.

If you have one panel in your Form then you can add Your user controls using,
UserControl1 uc1 = new UserControl1();
pnl.Controls.Add(uc1)



并且您需要在Loop中添加以上代码以生成多个控件.

希望这就是你想要的.

谢谢
-Amit Gajjar



And you need to add above code in Loop to generate multiple control.

Hope this is what you want.

Thanks
-Amit Gajjar


这篇关于如何在C#Windows应用程序中使用用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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