private async void Populate_Files() { Label l1 = new Label(); Label l2 = new Label(); Label l = new Label(); Button dis = new Button(); flag4 = false; panel3.Controls.Clear(); int xPos = 4; //coordinates of wifi buttons int yPos = 4; String [] files = req.getfilelist("0c:1d:af:77:a2:7a").Split(','); length = files.Length; Button[] btnArray = new Button[length]; int dist = 0; int xpic = 333; int ypic = 19; int xlabel = 237; int ylabel = 13; int xlabel1 = 9; int ylabel1 = 50; int xlabel2 = 9; int ylabel2 = 35; int xdisc = 242; int ydisc = 43; for (int i = 0; i < length; i++) { int h1 = 5; int w1 = 3; int x = 320; //coordinates of wifi signal int y = 23 + dist; btnArray[i] = new System.Windows.Forms.Button(); btnArray[i].Width = 350; // size of wifi button btnArray[i].Left = xPos; btnArray[i].Top = yPos; btnArray[i].Text = files[i]; btnArray[i].ForeColor = Color.RoyalBlue; btnArray[i].TabStop = false; btnArray[i].BackColor = Color.White; btnArray[i].FlatStyle = FlatStyle.Flat; btnArray[i].FlatAppearance.BorderSize = 0; btnArray[i].FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); btnArray[i].Font = new Font("Cambria", 12); //btnArray[i].ForeColor = Color.MediumSeaGreen; btnArray[i].Height = 30; btnArray[i].TextAlign = ContentAlignment.MiddleLeft; yPos += 30; dist += 30; //used for wifi signal ypic += 30; btnArray[i].Click += new System.EventHandler(WifiConnect); ydisc += 30; ylabel += 30; ylabel1 += 30; ylabel2 += 30; panel3.Controls.Add(btnArray[i]); } }