471,627 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Is there LabelArray (VB6) in C#?

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
Dec 30 '05 #1
3 2487
Scott Starker wrote:
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.)
Dec 30 '05 #2
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[i] = new Label();
labelArray[i].Text = labelText[i];
}
Dec 31 '05 #3
Hmmm... I didn't think of it like that. Thanks.

If anyone has a problem with VB LabelArray you should check out
http://msdn.microsoft.com/library/de...visualcnet.asp
The article is about ButtonArray but it works just fine using LabelArray.

"David Veeneman" <da****@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
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[i] = new Label();
labelArray[i].Text = labelText[i];
}

Jan 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Kieran Benton | last post: by
3 posts views Thread by Peter | last post: by
16 posts views Thread by Ben Hannon | last post: by
66 posts views Thread by Mitchell S. Honnert | last post: by
10 posts views Thread by AK | last post: by
15 posts views Thread by Aalaan | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.