一个业余爱好者试图完成我的第一个真正的应用程序,所以提前谢谢你,如果这是一个菜鸟问题,我们深表歉意。
我有一个启用拖放的数据网格视图,其中填充了来自团队类的数据和一个字典,它根据索引为列表中的项目分配一个值。我还没有实现绑定,因为我还没有让它与拖放行重新排序一起工作。
teamList = new List<Team>(){
new Team("Redskins","WAS", "Washington"),
new Team("Cowboys", "DAL", "Dallas"),
new Team("Eagles", "PHI", "Philadelphia"),
new Team("Giants", "NYG", "New York"),
new Team("Packers", "GB", "Green Bay")
};
class Team
{
public string Mascot { get; private set; }
public string Key { get; private set; }
public string City { get; private set; }
}
Dictionary<int, int> powerValues = new Dictionary<int, int>(){
{1, 113},
{2, 110},
{3, 109},
{4, 108},
{5, 107}
};
private void printValues()
{ // add Team to DGV wiht PowerRank as index+1 and PowerValue based on Dictionary
int i = 0;
foreach (Team team in TeamList)
{
// add all data to a datagrid view
dataGridView1.Rows.Add(i+1, team.Mascot,powerValues[teamList.IndexOf(team) + 1]); //set the rank
i++;
}
}
一旦达到这一点,我将尝试做两件事:
1) Update List<Team> based on drag and drop change
2) Re-assign PowerRank and PowerValue based on new index of Team
我尝试了几件事无济于事-有正确方向的想法或要点吗?