0

我有一个用 C# 编写的窗口应用程序。我里面有一个datagridview。这是代码:

private List<Tablet> tabletList = new List<Tablet>();
...

private void tabControl1_Selected(object sender, TabControlEventArgs e)
{
    GetTabletList();
}

void GetTabletList()
{
    Tablet newTablet = new Tablet();
    newTablet.xxx = yyy;
    newTablet.xxx2 = yyy2;
    tabletList.Add(newTablet);

    dataGridView.DataSource = tabletList;
    Console.WriteLine(tabletList.Count);
}

public class Tablet
{
    public string xxx { get; set; }
    public string xxx2 { get; set; }
}

每次我调用GetTabletList()时,值tabletList.Count都会不断增加,但我只能在 datagridview 中看到 1 行。怎么了?

4

1 回答 1

0

尝试ObservableCollection<Tablet>代替List<Tablet>

于 2013-03-29T07:34:43.260 回答