views:

13

answers:

1

Hi All,

I have a form and am creating controls, adding them at runtime. How do I get access to those controls without using controlcollection.

If I use controlcollection loop the system is getting hanged for a while.

Is there any other way to access that control?

Thanks in Advance.

A: 

Not sure what language you are using but if you know the name of the control you can use the control collection and simply get a control with the specified name. This does not require you to loop through anything.

Getting a runtime control without accessing the controlcollection as far as i am aware is impossible.

For example some runtime logic i use myself is as follows:

object c = this.Controls.Find("nameOfTheControl", false);
F.B. ten Kate
I know the control name. How do I use that?
Ramesh
Edited my post to add the code hope that helps, added it in C# but changing it to VB shouldn't be hard :).
F.B. ten Kate
this.Controls is the controls collection. The code above uses it. The author of the question doesn't want to do this. My answer: I don't think it is possible - there's a control tree which contains all controls and you have to get one. Even if you don't use the controls collection explicitly, the method you use (like Find()), probably does.
Slavo
The author does say that, how ever what the author really wants is to access the control without causing the application to hang. What is causing the application to hang is the looping, my solution does not cause the looping and therefor is alot more usefull then simply "It's not possible"
F.B. ten Kate