当前位置: 首页 > news >正文

TreeList

https://documentation.devexpress.com/#WindowsForms/CustomDocument2434

添加列

   TreeListColumn column = treeList1.Columns.Add();
            column.Caption = @"建筑列表";
            column.VisibleIndex = 0;

 

添加节点

https://documentation.devexpress.com/#WindowsForms/DevExpressXtraTreeListNodesTreeListNodes_Addtopic(5DdNJQ)

treeList1.Nodes.Add(new object[] {item});

This method calls the TreeList.AppendNode(nodeData, ParentNode) method. The ParentNode property's value is passed as the method's second parameter. See the TreeList.AppendNode topic to learn more.

 

 

https://documentation.devexpress.com/#WindowsForms/DevExpressXtraTreeListTreeList_AppendNodetopic(qybC6w)

下面的代码,演示了添加多个列

private void Form1_Load(object sender, EventArgs e) {
    CreateColumns(treeList1);
    CreateNodes(treeList1);
}

private void CreateColumns(TreeList tl) {
    // Create three columns.
    tl.BeginUpdate();
    tl.Columns.Add();
    tl.Columns[0].Caption = "Customer";
    tl.Columns[0].VisibleIndex = 0;
    tl.Columns.Add();
    tl.Columns[1].Caption = "Location";
    tl.Columns[1].VisibleIndex = 1;
    tl.Columns.Add();
    tl.Columns[2].Caption = "Phone";
    tl.Columns[2].VisibleIndex = 2;
    tl.EndUpdate();
}

private void CreateNodes(TreeList tl) {
    tl.BeginUnboundLoad();
    // Create a root node .
    TreeListNode parentForRootNodes = null;
    TreeListNode rootNode = tl.AppendNode(
        new object[] { "Alfreds Futterkiste", "Germany, Obere Str. 57", "030-0074321" }, 
        parentForRootNodes);
    // Create a child of the rootNode
    tl.AppendNode(new object[] { "Suyama, Michael", "Obere Str. 55", "030-0074263" }, rootNode);
    // Creating more nodes
    // ...
    tl.EndUnboundLoad();
}

 

禁用编辑

禁用TreeList

   treeList1.OptionsBehavior.Editable = false;

 

禁用单个列

    TreeListColumn column = treeList1.Columns.Add();
            column.Caption = @"建筑列表";
            column.VisibleIndex = 0;
            column.OptionsColumn.AllowEdit = false;
            column.OptionsColumn.ReadOnly = true;

 

 

设置选中行的背景色

TreeList.Appearance.FocusedRow

https://www.devexpress.com/Support/Center/Question/Details/Q419028

To solve the issue, disable the TreeList.OptionsSelection.EnableAppearanceFocusedCell option.

 

 

标题

必须先添加列,才能有标题(标题是列标题,TreeList本身的Caption是不显示的)

 

添加节点图片

http://www.cnblogs.com/zzh1236/archive/2012/06/29/2570057.html

1.添加一个ImageCollection,控件名为imageCollection1 【多个form共用的话,可以使用SharedImageCollection】

   按照节点的层级顺序添加图片

2. 设置TreeList的ColumnsImageList,SelectImageList,StateImageList为imageCollection1

3. 注册TreeList的CustomDrawNodeImages事件

treeList1.CustomDrawNodeImages += TreeList1_CustomDrawNodeImages;
private void TreeList1_CustomDrawNodeImages(object sender, CustomDrawNodeImagesEventArgs e)
{
e.SelectImageIndex = e.Node.Level;
}

 

NodeImage

概念:https://documentation.devexpress.com/#WindowsForms/CustomDocument1073

Nodes can display two images.

  • Select Image - Typically indicates the node selection (focus) state. However, the same select image can be displayed for a node regardless of the node state. The TreeList provides a mechanism to automatically substitute替代 a select image when a node receives/loses focus.
  • State Image - Typically indicates any state of a node.

If both select and state images are specified, the select image is displayed first.

 

The table below lists the main properties affecting element appearance.

 

 

 

控制节点的高度

https://documentation.devexpress.com/#WindowsForms/DevExpressXtraTreeListTreeList_CalcNodeHeighttopic

Allows you to assign custom node height.

EventData

The event handler receives an argument of type CalcNodeHeightEventArgs containing data related to this event.

The following CalcNodeHeightEventArgs properties provide information specific to this event.

Node Gets the current Tree List node.
NodeHeight Gets or sets the current node's height in pixels.

Remarks

Write a CalcNodeHeight event handler to assign custom node height for the TreeList control.

The event fires for each visible node each time a node's look & feel is affected.

The parameter transmitted to the event allows you to identify a node whose height is calculated and assign the appropriate custom height.

 

Note: the CalcNodeHeight event fires only if the TreeListOptionsBehavior.AutoNodeHeight option is disabled.

Use the CalcNodeHeight event if you want to assign different node heights to the TreeList control.

If you want to assign the same height to all nodes, use the RowHeight property instead.

 

相关文章:

  • 【故障处理】IMP-00010错误 12C的dmp文件导入11G
  • 笔记:表单序列化 serialize()
  • 实时优化算法实现智能物流平台
  • hive 空值、NULL判断
  • H5中JavaScript常用代码片段
  • Qt之QAbstractItemView视图项拖拽(二)
  • mysql中使用 where 1=1和 0=1 的作用
  • 括号
  • ssh远程登录讲解
  • Linux系统备份与恢复
  • libcurl
  • Eureka的故事,专注能让你看到别人看不到的事情
  • 锤子科技官方首页的特效
  • 知识获取、管理与知识体系的完善
  • Web Storage相关
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • Android路由框架AnnoRouter:使用Java接口来定义路由跳转
  • CNN 在图像分割中的简史:从 R-CNN 到 Mask R-CNN
  • EOS是什么
  • HashMap剖析之内部结构
  • Java多线程(4):使用线程池执行定时任务
  • mysql中InnoDB引擎中页的概念
  • python学习笔记 - ThreadLocal
  • React组件设计模式(一)
  • Unix命令
  • Vim Clutch | 面向脚踏板编程……
  • 规范化安全开发 KOA 手脚架
  • 诡异!React stopPropagation失灵
  • 好的网址,关于.net 4.0 ,vs 2010
  • 基于Vue2全家桶的移动端AppDEMO实现
  • 判断客户端类型,Android,iOS,PC
  • 阿里云IoT边缘计算助力企业零改造实现远程运维 ...
  • 国内开源镜像站点
  • #define,static,const,三种常量的区别
  • #LLM入门|Prompt#2.3_对查询任务进行分类|意图分析_Classification
  • (3)选择元素——(14)接触DOM元素(Accessing DOM elements)
  • (day 12)JavaScript学习笔记(数组3)
  • (算法)Game
  • (一一四)第九章编程练习
  • (中等) HDU 4370 0 or 1,建模+Dijkstra。
  • (转)eclipse内存溢出设置 -Xms212m -Xmx804m -XX:PermSize=250M -XX:MaxPermSize=356m
  • ***测试-HTTP方法
  • .[hudsonL@cock.li].mkp勒索病毒数据怎么处理|数据解密恢复
  • .bashrc在哪里,alias妙用
  • .mysql secret在哪_MYSQL基本操作(上)
  • .net framework 4.0中如何 输出 form 的name属性。
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .NET 常见的偏门问题
  • @cacheable 是否缓存成功_让我们来学习学习SpringCache分布式缓存,为什么用?
  • [4.9福建四校联考]
  • [AI]文心一言出圈的同时,NLP处理下的ChatGPT-4.5最新资讯
  • [AIGC] Redis基础命令集详细介绍
  • [BZOJ4554][TJOI2016HEOI2016]游戏(匈牙利)
  • [C++]AVL树怎么转
  • [CISCN2019 华东南赛区]Web4