I want to create labels based on an array, but i always get only one label.
private void button1_Click(object sender, EventArgs e)
{
Debug.WriteLine(hardrive.GetHardDriveName.Count);
Label[] lblHDDName = new Label[hardrive.GetHardDriveName.Count];
for (int i = 0; i < hardrive.GetHardDriveName.Count; i++)
{
int x = 10;
int y = 10;
lblHDDName[i] = new Label();
lblHDDName[i].Location = new System.Drawing.Point(x, y);
lblHDDName[i].Text = "Test";
groupBoxHDD.Controls.Add(lblHDDName[i]);
y += 10;
}
}
Debugging
Debug.WriteLine(hardrive.GetHardDriveName.Count);
Shows two items in the array.
The problem is that in the GroupBox there is only one label instead of two.