There was never any error for adding controls with the same name. You can
always write a generic post processing method to expose any repeating
named elements of similar types as arrays of controls. The perf is always
better doing the post InitializeComponent, or using a real array, but if you
plan on changing the number of elements by dynamically creating new
controls then maybe a growing list (ArrayList) isn't such a bad idea.
ControlAdded/Removed events round out your arsenal for applying a truly
bolt-on component and still having it work as a control array grouper.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog:
http://weblogs.asp.net/justin_rogers
"Chris Ballard" <wo*********@typeYAHOOhere.com> wrote in message
news:9C**********************************@microsof t.com...
Christopher,
As Jon says you can create an array of controls. However, these controls do
not appear in the form designer, which may or may not be a problem for you.
If this is a problem, the I would suggest you add the controls using the
designer as normal, and then in addition add references to these controls
into an array once InitializeComponent() has been called.
It is a shame that there isnt a mechanism to do this in the form designer,
as per VB6 - it seems like a backward step.
Chris.
"Jon Skeet [C# MVP]" wrote:
Christopher <Ch*********@discussions.microsoft.com> wrote: > I need to know how to work with a control array in c#. I would
> like to clear the contents of a textbox array after adding up the
> values in the textboxes. This is really easy in VB6 - im sure it easy
> in C# aswell - i just need the syntax.
There's no specific control array semantics in C#. You just need to
create an array of controls, and then you can iterate through them
clearing them or whatever.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too