使用TableLayoutPanel创建排行榜

时间:2017-03-12 18:08:05

标签: c# winforms visual-studio loops

Visual C#。寻找一种方法来遍历TableLayoutPanel的标签以显示用户名和分数。该列表按分数降序排序。

label1.Text = SortedList[0].Username; label2.Text = Convert.ToString(SortedList[0].Score);
label3.Text = SortedList[1].Username; label4.Text = Convert.ToString(SortedList[1].Score);
label5.Text = SortedList[2].Username; label6.Text = Convert.ToString(SortedList[2].Score);
//Continues until I have 10 rows.

我这样写它是为了表明每一行都是一行。我希望这使我在这里想要实现的目标更加明确。

2 个答案:

答案 0 :(得分:0)

我会做这样的事情:(抱歉,自从我完成WinForms以来已经有一段时间了)

<a href="/192.168.1.125:8080">

答案 1 :(得分:0)

我认为这项工作的正确工具是DataGridView

//below property is true by default - will generate columns for properties automatically
yourDataGridView.AutoGenerateColumns = true;
yourDataGridView.DataSource = SortedList;
相关问题