如何在RadTreeView中绑定多个节点

时间:2016-07-28 12:19:05

标签: c#

问题:

如何在RadTreeView中绑定多个节点

这是我的代码:

if (lblCategory != null && lblCategory.Text != string.Empty && rtCategory != null)
 {
     string[] tree = lblCategory.Text.Split(',');

     for (int i = 0; i < tree.Length; i++)
     {                      
         foreach (RadTreeNode t in rtCategory.Nodes)
         {                           
             if (t.Value == tree[i])
             {
                 t.Selected = true;
             }
         }

     }
         rtCategory.ExpandAllNodes();
}

1 个答案:

答案 0 :(得分:1)

if(lblCategory!= null&amp;&amp; lblCategory.Text!= string.Empty&amp;&amp; rtCategory!= null)                 {                     string [] tree = lblCategory.Text.Split(',');

                for (int i = 0; i < tree.Length; i++)
                {

                    foreach (RadTreeNode t in rtCategory.GetAllNodes())
                    {                           
                        if (t.Value == tree[i])
                        {
                            t.Selected = true;
                        }
                    }

                }
                rtCategory.ExpandAllNodes();
            }

在foreach条件中使用GetAllNodes()而不是Node