本文介绍了我可以使用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.

推荐答案


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;在窗口中找出动态添加的控件吗? .网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 22:10