Is there LabelArray (VB6) in C#?

S

Scott Starker

Greetings all.

I have a program that I've written in VB6 and now want to re-code in C#. But
I have a problem in that there is no LabelArray in C# like there is in VB6.
Is there any easy way to do this VB6 LabelArray in C#?

Scott
 
J

James Moore

Scott said:
Greetings all.

I have a program that I've written in VB6 and now want to re-code in C#. But
I have a problem in that there is no LabelArray in C# like there is in VB6.
Is there any easy way to do this VB6 LabelArray in C#?

Scott

I think the most natural way would be to create a collection of the
labels and add them to the form programatically.

Probably seems like a pain in the ass compared to VB but when you get
into it, it is no problem. I tried it with .net 2 and the new generic
List class simplified it somewhat. You could probably simplify it
further by extending the List to handle some of the stuff you have to do
programatically (setting coordinates, naming, tabindex etc.)
 
D

David Veeneman

You could also declare it like this, assuming a 5-label array:

Label[] labelArray = new Label[5];
string[] labelText = new string[] { "Label 0", "Label 1", "Label 2", "Label
3", "Label 4" };
for (int i = 0; i < 5; i++)
{
labelArray = new Label();
labelArray.Text = labelText;
}
 

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