有了这个:
dataGridView.DataSource = theData.Select((x, index) =>
new { CreatureRoll = x, CreatureLabel = index}).OrderByDescending(x => x.CreatureRoll).ToList();
它正确地生成数据,但它生成数组中的所有行,其中包含无用的额外数据,即空数据。
图片http://s21.postimg.org/t3f34aa43/list_Result.jpg?noCache=1379353500
想要删除不必要的数据行
你也可以有这样的代码,
dataGridView1.Columns.Add("Index", "Index");
dataGridView1.Columns.Add("Value", "Dice Value");
int[] theData = new int[] { 5, 2, 1, 5, 4, 1, 3, 1};
for (int i = 0; i < theData.Length; i++)
{
dataGridView1.Rows.Add(new object[] { i+1, theData[i] });
}
Output
![enter image description here](https://i.stack.imgur.com/jP0L5.png)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)