在C#中将用户控件动态添加到面板中 [英] Adding a User Control to the Panel dynamically in C#

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

问题描述

你好,

在将UserControl动态添加到面板中时,我需要一些帮助.

我使用的UserControl具有三个文本框,当我单击添加按钮时,应将带有这三个文本框的Usercontrol添加到面板中.

第一次单击就可以正常工作,我的意思是,当我第一次单击添加时,它会将用户控件添加到面板中,但是当我再次单击时,它只是替换了唯一的文本框.不会在面板中添加一对新的文本框.

请帮助我添加用户控件.

谢谢大家.

Hello,

I need some help in adding a UserControl to the panel dynamically.

I am using a UserControl has threee textboxes, when i click add button,It should add the Usercontrol with those three textboxes to the Panel.

It''s working fine for the first click, I mean when i click add for the first time it''s adding the User control to the Panel,But when i click again , it''s just replacing the only textboxes. its not adding a new pair of textboxes to my Panel.

Please help me in adding the User Control.

Thank you guys in advance.

推荐答案

您确定要替换它们吗?不只是将新的放在顶部吗?

如果在创建新文本框时指定相对于面板TLHC的位置,则必须为已添加的文本框抵消一定数量的最高帐户.

在添加"按钮上放置一个断点,然后逐步执行-您应该以这种方式找到它.
Are you sure it''s replacing them? Not just putting new ones over the top?

If when you create the new text boxes you specify the location relative to the TLHC of the panel, you will have to offset them by some amount top account for the ones you already added.

Put a breakpoint on your Add button, and single step through - you should find it that way.


我相信以下网址可以为您提供帮助

动态添加和删除用户控件 [
I believe the following URL can help you

Dynamically add and remove user controls[^]


这篇关于在C#中将用户控件动态添加到面板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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