• DevExpress控件之TreeList


    基于v18.1

    使用AppendNode方法手动赋值时,首先要添加treeListColumn

    默认样式                                     修改后的样式

     

    1 隐藏TreeList的列头

    设置OptionsView下ShowColumns=False

    2 隐藏竖直水平线

    设置OptionsView下ShowHorzLines、ShowVertLines=False

    3 隐藏左侧Node的指示符面板

    设置OptionsView下ShowIndicator=False

    4 禁止编辑节点

    设置OptionsBehavior下Editable=False

    5、 如何默认展开所有的节点,   ExpandAll()

        treeList1.ExpandAll();

        以及TreeNode.Expand = false;

        或者你可以控制展开的层数 treeList1.ExpandLevel = 10;

        表示: 展开10层

     

      // 第一层下的所有接点展开

      treeList1.Nodes[0].ExpandAll();

    6. 去掉边框

    BorderStyle=NoBorder

    添加节点方法

    this.treeList1.BeginUnboundLoad();
    
    this.treeList1.AppendNode(new object[] {
    "111"}, -1);
    this.treeList1.AppendNode(new object[] {
    "222"}, 0);
    this.treeList1.AppendNode(new object[] {
    "444"}, 1);
    this.treeList1.AppendNode(new object[] {
    "333"}, -1);
    this.treeList1.EndUnboundLoad();

    节点折叠 

    treeList1.CollapseAll();

    7.TreeList丢失焦点时,也处于高亮选中状态 (设置treeList节点的背景色)

    treeList1.Appearance.FocusedCell.BackColor = System.Drawing.Color.LightSteelBlue;

    treeList1.Appearance.FocusedCell.Options.UseBackColor = true; (默认是true)

    二。treeList获取目录下的所有文件及文件夹

    treeList1.Nodes.Clear();
    TreeListNode rootNode=  this.treeList1.AppendNode(new object[] { rootFilePath }, -1);
    TreeListNode firstNode = getRootListNode(treeList1, rootFilePath, 0);
    private static TreeListNode getRootListNode(DevExpress.XtraTreeList.TreeList treeListFiles, string dirname, int nodeID) //递归,返回根结点
    {
        if (!Directory.Exists(dirname))
            return null;
    
        string[] dirs = Directory.GetDirectories(dirname);
        string[] files = Directory.GetFiles(dirname);
    
        foreach (string dir in dirs)
        {
            TreeListNode root2 = treeListFiles.AppendNode(new object[] { dir.Substring (dir.LastIndexOf('\')+1) }, nodeID);
            root2.Tag = dir;
    
            TreeListNode node2 = getRootListNode(treeListFiles, dir, root2.Id);
        }
    
    
        foreach (string file in files)
        {
            TreeListNode node2 = treeListFiles.AppendNode(new object[] { file.Substring (file.LastIndexOf('\')+1) }, nodeID, 1, 1, 0);
            node2.Tag = file;
        }
    
        return treeListFiles.Nodes.FirstNode;
    }

    参考 :DevExpress_常用控件23_TreeList

  • 相关阅读:
    参数探测(Parameter Sniffing)与影响计划重用的SET选项
    The workbook can not be opened
    参数Sniffing问题
    Unable to connect SQL Server
    正则|和[]的区别
    form的target捕捉不到动态写入name的iframe
    windows下git bash乱码问题
    ie6,7下textarea等上方空白
    根据字数截取字符串,不能截断url
    浏览器hack
  • 原文地址:https://www.cnblogs.com/code1992/p/10437523.html
Copyright © 2020-2023  润新知