Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 4th, 2003, 09:53 PM
Authorized User
 
Join Date: Oct 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Collection of Controls?

I have what is probably a very simple question, but it has me stumped. Is it possible to have a collection of controls? I have about 30 instances of a custom control on my form and at times would like to be able to treat the controls as a group. ie.

For x = 0 to 29
    myCollection(x).justdoit
Next

I have figured out how to create the collection as a class (inheriting Collection.Base). I have created methods that add my controls the list and an index as a property, but I am having trouble adding the controls that I have already created on my form, onto the collection.

Any ideas??
 
Old November 5th, 2003, 11:05 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is built into every control in .Net. Everything from the Page class on down comes from System.Web.UI.Control and on it is a ControlCollection property. You could use an instance of that collection and add all your custom controls to it.

http://msdn.microsoft.com/library/de...classtopic.asp

Peter
----------------------------------------
Work smarter, not harder.
 
Old November 5th, 2003, 04:18 PM
Authorized User
 
Join Date: Oct 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Excellent! Thank you for that Peter.








Similar Threads
Thread Thread Starter Forum Replies Last Post
The Controls collection cannot be modified... VerbatimBOT ASP.NET 2.0 Professional 2 October 22nd, 2007 09:43 AM
System.Web.UI.Control.Controls Collection Ihoulun ASP.NET 1.0 and 1.1 Basics 0 October 17th, 2006 07:51 AM
Collection in C# ? dedex C# 1 January 14th, 2005 04:51 PM
urgent custom control with collection of controls dd_smith Pro VB.NET 2002/2003 1 December 19th, 2004 06:05 PM
COM Collection ben0027 Visual C++ 0 May 1st, 2004 05:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.