我可以使用C#和amp;在窗口中找出动态添加的控件吗? .网? [英] can i find out dynamic added control in window using C# & .net?

查看:47
本文介绍了我可以使用C#和amp;在窗口中找出动态添加的控件吗? .网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了这样的动态控件
TextBox txnew =新的TextBox();
txnew.Location = new Point(34,34);
this.Controls.Add(txnew);
并想找出按钮点击事件
Control [] mycon = this.Controls.Find("txnew",true);
但我没有发现
请告诉我我错了.

i have created a dynamic control like that
TextBox txnew = new TextBox();
txnew.Location = new Point(34, 34);
this.Controls.Add(txnew);
and want to find out in button click event
Control[] mycon = this.Controls.Find("txnew", true);
but i did''nt find out
plz tell me where i m wrong.

推荐答案

正如其他人所说,您的基本问题是完全不了解自己在做什么.更重要的是,您问两次相同的问题是很不礼貌的.
As someone else said, your basic problem is a complete lack of understanding of what you''re doing. More to the point, it''s rude of you to ask the same question twice.


您错过了这一点:
You have missed this:
TextBox txnew = new TextBox();
txnew.Name = "txnew"; // You must set the name in order to find the control later

txnew.Location = new Point(34, 34);


这篇关于我可以使用C#和amp;在窗口中找出动态添加的控件吗? .网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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