Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
want to find out dynamic added control in window using C# & net.Can i find it or not.
Posted

The logical thing to do, is to not lose it, that is, to not add a control without keeping a reference to it. However, you can iterate recursively through your controls collection and search for the control, if you need to.
 
Share this answer
 
You haven't set the name for the textbox. Find method searches based on the Name property of the controls. Set the Name property for the textbox and it will work.

A better way to do this would be make that TextBox object a class level object so that you don't need to search for it again and again.
 
Share this answer
 
You has forget to set name property. set it like
txnew.Name="txnew";

Then it will work for you.
 
Share this answer
 
Can you describe what exactly are you looking for?
 
Share this answer
 
You could enumerate all child controls from the roignal form template and compare the list to all of the controls enumerated from the loaded form.

Reflection is your friend.
 
Share this answer
 
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.
 
Share this answer
 
Oh, Is this C# Language? I have no idea about it, What a shame. :omg:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900