Windows Develop Bookmark and Share   
 index > Windows Forms General > Help converting string array to Label Control array
 

Help converting string array to Label Control array

Hi,

Im fairly new to C# and am writing my first application for a work project. I have a string array containing data, and on my form i have a created a control array for all my Labels that display data.

Is there a way that i can copy the data in my string array to the control array ?

Ive looked on MSDN and read the "Array.ConvertTo" and to be honest just confused me.

If anyone could tell me how to that would be great!

Thanks

Paul

PaulMB  Sunday, June 03, 2007 10:09 PM
In essence you want to assign your string to (egSmile Control's Text property...

Code Snippet

if (myLabels.Length != myStrings.Length)

{

throw new ArgumentException("Length of labels and strings array is not the same");

}


for (int i = 0; i < myLabels.Length; ++i)
{
myLabels[i].Text = myStrings[i];
}



timvw  Sunday, June 03, 2007 10:15 PM
In essence you want to assign your string to (egSmile Control's Text property...

Code Snippet

if (myLabels.Length != myStrings.Length)

{

throw new ArgumentException("Length of labels and strings array is not the same");

}


for (int i = 0; i < myLabels.Length; ++i)
{
myLabels[i].Text = myStrings[i];
}



timvw  Sunday, June 03, 2007 10:15 PM

You can use google to search for other answers

Custom Search

More Threads

• how to know the taskbar height and where it is being displayed(top or down)?
• how to add\edit resource(resx) files
• hai
• Cursor.Current = Cursors.WaitCursor doesn't work
• C# show new form vs vb way
• Change Mouse Cursor
• Problem creating and display new instance of label class
• send message to other process
• on-screen keyboard
• How can I disable text zoom in RichTextBox when holding the Ctrl key and mouse wheeling?