Creating control arrays at design time.

M

Mark Broadbent

In VB6 (using visual studio) it was possible to create a control array at
design time by simply adding the control (e.g. textbox) and renaming it to
what would become the first element
e.g.

Name => MyTextbox
to
Name => MyTextbox(1)

you could then copy this control array element and paste back onto form to
add a new element to the control array.
Is this possible using Visual Studio 2003? I've seen the following
http://msdn.microsoft.com/library/d...ngcontrolarraysinvisualbasicnetvisualcnet.asp
but cannot find anything about doing this at design time (it was sooooo easy
before!)

Any ideas/ thoughts anyone?

Cheers.

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
 
D

Dilip Krishnan

It is still easy depending on what you want to do. While VB had it to
help users create "dynamic" controls which was otherwise not possible
without control arrays, in C# you can create any number of controls and
add it to an array list and achieve the same thing.
 
M

Mark Broadbent

Hi Dilip, yeah had a play with the ArrayList with regards to this. You are
right it is relatively easy and gives me the functionality I had. Just a
couple of points on this though.
Firstly to access the textbox's as such I need to cast them to a TextBox
type (since they are added to the collection as Object), the control array
in VB6 was of the type of the first control (not object).
Secondly I am having to code functionality that the designer (in VS6)
previously did effortlessly by just naming a control using an index .

-I just hoped that the designer retained this functionality -regardless of
the code that is eventually generated.

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top