Four Symbols
February 20th, 2010, 04:45 PM
Basically, I have a huge amount of labels that correspond to notes on a guitar fretboard. When the form loads, I organize these into arrays so that it's easier to perform functions on them later.
Here's the code I'm using to convert the label into a label array:
Label[] lblFretboardInterval_0 = new Label[12];
int i = 0; while (i < 12)
{
lblFretboardInterval_0[i] = (Label)this.Controls["Label" + Convert.ToString(1 + i)];
}
For simplicity I've only showed one of the labels, but I have lblFretboardInterval_1, _2, _3 and so forth up to 11.
Now, Here's my problem: If I put the labels inside of a TabPage, the code above won't work. It's trying to find the labels, but since they're inside the TabPage it's not referencing correctly. I've researched this, but can't find a way to reference the labels when they are inside of a TabPage.
If anyone knows a way to do this I would be very thankful. Thanks in advance for your help!
Here's the code I'm using to convert the label into a label array:
Label[] lblFretboardInterval_0 = new Label[12];
int i = 0; while (i < 12)
{
lblFretboardInterval_0[i] = (Label)this.Controls["Label" + Convert.ToString(1 + i)];
}
For simplicity I've only showed one of the labels, but I have lblFretboardInterval_1, _2, _3 and so forth up to 11.
Now, Here's my problem: If I put the labels inside of a TabPage, the code above won't work. It's trying to find the labels, but since they're inside the TabPage it's not referencing correctly. I've researched this, but can't find a way to reference the labels when they are inside of a TabPage.
If anyone knows a way to do this I would be very thankful. Thanks in advance for your help!