【问题标题】:Is there any to set the visibility of xtra tree list nodes dynamically是否可以动态设置 xtra 树列表节点的可见性
【发布时间】:2013-05-20 10:52:00
【问题描述】:

我在我的应用程序中使用 xtratreelist,只有一级,我想让一些节点可见,但不是全部。这是代码,但之后所有的都没有显示在列表中

TreeList tr = new Treelist();

for (int x = 0; x < tr.Nodes.Count; x++)
{
    tr.Nodes[x].Visible = false;
}

【问题讨论】:

    标签: c# devexpress xtratreelist devexpress-windows-ui


    【解决方案1】:

    我建议你使用NodesIterator,这是一个例子,它对我有用:

    数据类:

    public class Service
    {
        public string Name { get; set; }
        public bool Visible { get; set; }
    }
    

    以我的形式:

    private void TreeForm_Load(object sender, EventArgs e)
    {
         treeList1.DataSource = Service.GetServices();
         treeList1.NodesIterator.DoLocalOperation(setNodeVisibility, treeList1.Nodes);
    }
    
    private void setNodeVisibility(DevExpress.XtraTreeList.Nodes.TreeListNode node)
    {
         var service = treeList1.GetDataRecordByNode(node) as Service;
         if (service == null)
             return;
    
         node.Visible = service.Visible;
    }
    

    【讨论】:

      【解决方案2】:

      【讨论】:

      • 我得到了这样的目标节点 TreeListNode node = tr.FindNodeByKeyID(key_id); node.Visible = false;但不隐藏节点
      • 你有什么异常吗??
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多