zoukankan      html  css  js  c++  java
  • dev treelist和searchcontrol组合模糊查询用法

    这里需要用到两个控件,是dev的treelist和searchcontrol,首先呢树形控件要形成树形我在这就不多说了 

    因为这里是记录下searchcontrol这控件的用法

    首先写这三行代码,里面都有注释

    this.searchControl1.Client = this.treeList1;//设置搜索绑定
                treeList1.OptionsBehavior.EnableFiltering = true;//开启过滤功能
                treeList1.OptionsFilter.FilterMode = FilterMode.Smart;//过滤模式
    View Code

    然后我们构造一个事件,我们称它为过滤事件,

    //过滤事件
                treeList1.FilterNode += treeList1_FilterNode;

    然后在事件中写上代码

    void treeList1_FilterNode(object sender, DevExpress.XtraTreeList.FilterNodeEventArgs e)
            {
                if (treeList1.DataSource == null) return;
                string NodeText = e.Node.GetDisplayText("SCNAME");
                if (string.IsNullOrWhiteSpace(NodeText)) return;
                bool IsVisible = NodeText.ToUpper().IndexOf(searchControl1.Text.ToUpper()) >= 0;
                if (IsVisible)
                {
                    TreeListNode Node = e.Node.ParentNode;
                    while (Node != null)
                    {
                        if (!Node.Visible)
                        {
                            Node.Visible = true;
                            Node = Node.ParentNode;
                        }
                        else
                            break;
                    }
                }
                e.Node.Visible = IsVisible;
                e.Handled = true;
            }
    View Code

    到这里,如果你的树形数据没有问题的话,就能看到效果了 ,快去动手试试吧

  • 相关阅读:
    UIImage的使用
    UIImageVIew的使用
    关于View和VIewController的关系和理解
    ZT Android 4.2蓝牙介绍
    2013深秋红土地旅行计划之井冈山
    系统性能优化
    Reorder List
    Word Break II
    iOS.CocoaPods.0
    Python 知识要点:案例:士兵突击
  • 原文地址:https://www.cnblogs.com/liuhuimh/p/7632040.html
Copyright © 2011-2022 走看看