博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TreeList
阅读量:7229 次
发布时间:2019-06-29

本文共 3505 字,大约阅读时间需要 11 分钟。

添加列

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  property's value is passed as the method's second parameter. See the  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;

 

 

设置选中行的背景色

To solve the issue, disable the option.

 

 

标题

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

 

添加节点图片

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

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

2. 设置TreeList的,,为imageCollection1

3. 注册TreeList的CustomDrawNodeImages事件

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

 

NodeImage

概念:

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  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  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  property instead.

 

转载地址:http://rddfm.baihongyu.com/

你可能感兴趣的文章
30K iOS程序员的简述:如何快速进阶成为高级开发人员
查看>>
Go 夜读 - 每周四晚上 Go 源码阅读技术分享
查看>>
tranform知多少
查看>>
Android电量优化
查看>>
[爬虫手记] 我是如何在3分钟内开发完一个爬虫的
查看>>
【译】Css Grid VS Flexbox: 实践比较
查看>>
iOS 开发知识索引
查看>>
Linux iptables命令
查看>>
webpack的使用
查看>>
干货 | 基于Go SDK操作京东云对象存储OSS的入门指南
查看>>
D3.js入门
查看>>
一次和前端的相互甩锅的问题记录
查看>>
纯OC实现iOS DLNA投屏功能了解一下
查看>>
RxJava -- fromArray 和 Just 以及 interval
查看>>
LC #75 JS
查看>>
js正则验证代码库
查看>>
常见面试题—css实现垂直水平居中
查看>>
lc682. Baseball Game
查看>>
重学前端-css选择器
查看>>
iOS开发之扫描二维码
查看>>