Control arrays

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
Back
Top