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

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

  • 相关阅读:
    Ubuntu编译gdb-ARM调试环境
    12小时制字符串转24小时制字符串
    Qt QByteArray或者Char转十六进制 QString
    STM32 串口通信使用奇偶校验
    127.*.*.* 为本地回环地址,均返回127.0.0.1
    winform解析json
    qString转char*
    下载vc++运行库
    CentOS 7 通过 yum 安装 nodejs 和 npm
    go语言 工程目录
  • 原文地址:https://www.cnblogs.com/liuhuimh/p/7632040.html
Copyright © 2011-2022 走看看