Пример #1
0
        public void RefreshData()
        {
            var top10 = PlayerDAO.GetTop10();
            int i = 0, j = 0;

            if (top10 == null)
            {
                return;
            }

            foreach (Label l in tlpMainHS.Controls.OfType <Label>())
            {
                if (l.Name == $"lblTop{i + 1}")
                {
                    l.Text = top10[i].UserName;
                    i++;
                }
                else if (l.Name == $"lblScore{j + 1}")
                {
                    l.Text = top10[j].Score.ToString();
                    j++;
                }
            }

            //foreach (Label lbl in labels)
            //{
            //    if (nameof(lbl) == $"lblTop{i+1}")
            //    {
            //        lbl.Text = top10[i].UserName;
            //    }
            //    else if (nameof(lbl) == $"lblScore{i+1}")
            //    {
            //        lbl.Text = top10[i].Score.ToString();
            //    }

            //    i++;
            //}
        }