public void PaintKv() { while (true) { if (!isPause) { var t = InitPole.rndSampling(); var findLbl = this.Controls["lbl" + t.ToString("000")]; findLbl.BackColor = Color.Red; if (currentLabelNumber == 0) // срабатывает один раз, так как нумерация ячеек начинается с 1 { currentLabelNumber = 1; } findLbl = this.Controls["lbl" + currentLabelNumber.ToString("000")]; if (numSelectedQuestions.IndexOf(currentLabelNumber) != -1) // остается зеленым если был выбран { findLbl.BackColor = Color.Green; } else { findLbl.BackColor = Color.White; } currentLabelNumber = t; } Thread.Sleep(100); } }
// пишем текст на метке private void newGameLabelTxt() { int[] arr = InitPole.initNewGame(); int i = 0; foreach (Label lbl in this.arrLabel) { lbl.Text = arr[i].ToString(); lbl.Name = "lbl" + arr[i].ToString("000"); i = i + 1; } }