Jarod Posted March 25, 2003 Posted March 25, 2003 In Web development wa can use a method called System.Web.UI.Control.FindControl(string) to get a control by its ID. So in a Page (inheriting from Control by default) we can easily get any control of that page. Do I have missed the equivalent of that function for the System.Windows.Forms.Control ? I know we have access to the ControlCollection of a form but if I have a textBox on my Form named "TextBox1", how can I get it ? (can't use me.TextBox1 if the control has been added dynamically) No other solution to get an enumerator on the ControlCollection and test all control ???? Thanks, Quote Jarod
*Gurus* divil Posted March 25, 2003 *Gurus* Posted March 25, 2003 You'd have to loop through checking their .Name property I suppose. Controls don't really have names as such, so if you're creating them at runtime it's best to keep a reference to them around somewhere, either in a hashtable or you can just rely on the .Name property and loop through the Controls collection. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.