void resetCircles() { foreach (var item in groupBox1.Controls) { OvalPBox pb = (OvalPBox)item; pb.BackColor = Color.Black; } }
private void Form1_Load(object sender, EventArgs e) { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); foreach (var item in groupBox1.Controls) { OvalPBox pb = (OvalPBox)item; pb.Click += Pb_Click; } }
void setPassword() { randoms = new int[6]; Random rnd = new Random(); for (int i = 0; i < 6; i++) { randoms[i] = rnd.Next(1, 6); OvalPBox pb = (OvalPBox)groupBox1.Controls.Find((rows[i] + randoms[i]), true)[0]; pb.BackColor = Color.Cyan; } }