C# Treeview从Dictionary中绑定数据

有如下数据结构

Dictionary>> errorData = new Dictionary>>();

遍历进行绑定

foreach (string apartment in errorData.Keys)
{
 int i= treeView1.Nodes.Add(new TreeNode(apartment));
 foreach (string username in errorData[apartment].Keys)
  {
    int j= treeView1.Nodes[i].Nodes.Add(new TreeNode(username));
    foreach (string day in errorData[apartment][username])
        treeView1.Nodes[i].Nodes[j].Nodes.Add(new TreeNode(day));
  }
 }

效果如下(名字已打码)

C# Treeview从Dictionary中绑定数据_第1张图片

你可能感兴趣的:(C# Treeview从Dictionary中绑定数据)