TreeList
https://documentation.devexpress.com/#WindowsForms/CustomDocument2434
添加列
TreeListColumn column = treeList1.Columns.Add(); column.Caption = @"建筑列表"; column.VisibleIndex = 0;
添加节点
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.
下面的代码,演示了添加多个列
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.
控制节点的高度
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.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2014-11-08 操作数据库的时候,使用自带的DbProviderFactory类 (涉及抽象工厂和工厂方法)
2014-11-08 8.2.4对象之间的关系