I am new to C# so sorry if this is a silly question!
I currently have 3 forms in my code, I want to change the location of a label that is on the third form. Here is part of the code where i tried to specify this:
Form ThirdForm = new Form();
int horizontalCount;
ThirdForm.label[horizontalCount - 1].Top = label[16].Top;
ThirdForm.label[horizontalCount - 1].Left = label[16].Left;
This returns the error:
Error CS1061 'Form' does not contain a definition for 'label' and no extension method 'label' accepting a first argument of type 'Form' could be found (are you missing a using directive or an assembly reference?) HID PnP Demo
The labels are added to the form using this method:
Label[] createlabels(Image[] tiles, Bitmap Img, int[] tileOrder, Form form)
{
int i = 0; int val;
for (int j = 0; j < ROW_COUNT; j++)
for (int k = 0; k < COLUMN_COUNT; k++)
{
//val = gridVal[j, k];
label[i] = new Label();
label[i].Font = new Font("Microsoft Sans Serif", 15F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
label[i].Width = Img.Width / COLUMN_COUNT;
label[i].Height = Img.Height / ROW_COUNT;
label[i].Left = k * (int)label[i].Width;
label[i].Top = j * (int)label[i].Height;
label[i].Tag = 0;
label[i].TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
if (i != 15)
{
string LabelNumber = i.ToString();
string TileNumber = tileOrder[i].ToString();
label[i].Image = tiles[tileOrder[i]];
label[i].BorderStyle = BorderStyle.FixedSingle;
label[i].Text = TileNumber;
}
else
{
label[i].BackColor = Color.Black;
label[i].BorderStyle = BorderStyle.None;
label[i].Text = "";
label[i].Visible = false;
z = i;
whiteTileLeftLocation = label[i].Left;
whiteTileTopLocation = label[i].Top;
verticalCount = 4;
horizontalCount = 4;
}
form.Controls.Add(label[i]);
i++;
}
return label;
}
What am I doing wrong?
Any help is greatly appreciated!