Control arrays

G

Guest

Hi all,

I would like to know what is the best way to create control arrays of Labels
and be able to index them? I am a former VB6 programmer that was used to
plopping controls on the form and have the arrays created automatically.
Please provide a snippet of code or good reference site on C# on how to do
this thanks.
 
M

Michael C

Joseph said:
Hi all,

I would like to know what is the best way to create control arrays of
Labels
and be able to index them? I am a former VB6 programmer that was used to
plopping controls on the form and have the arrays created automatically.
Please provide a snippet of code or good reference site on C# on how to do
this thanks.

There's a couple of different ways (which are basically the same). The first
is to plonk the controls on the form as normal and then create an array of
labels and populate it yourself

Label _LabelArray = new Label[3];
_LabelArray[0] = Label0;
_LabelArray[1] = Label1;
etc

The second is to create the labels yourself and populate the above array.

This is more work than VB6 but provided much greater functionality. The vb6
control arrays were not that good for a few reasons.
 

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