向DevExpress.TreeList控件中添加Column    

1、添加引用

using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;

2、清除已有Columns

this.treelist.Columns.Clear();

3、添加代码

TreeListColumn tc1 = new TreeListColumn();
tc1.Caption = "图书编号";
tc1.VisibleIndex = 0;//此为必须设置的属性,否则无法显示列

TreeListColumn tc2 = new TreeListColumn();
tc2.Caption = "书名";
tc2.VisibleIndex = 1;

TreeListColumn tc3 = new TreeListColumn();
tc3.Caption = "编目";
tc3.VisibleIndex = 2;

TreeListColumn tc4 = new TreeListColumn();
tc4.Caption = "出版日期";
tc4.VisibleIndex = 3;

TreeListColumn tc5 = new TreeListColumn();
tc5.Caption = "作者";
tc5.VisibleIndex = 4;

TreeListColumn tc6 = new TreeListColumn();
tc6.Caption = "出版社";
tc6.VisibleIndex = 5;

TreeListColumn tc7 = new TreeListColumn();
tc7.Caption = "册数";
tc7.VisibleIndex = 6;

this.treelist.Columns.AddRange(new TreeListColumn[] { tc1,tc2,tc3,tc4,tc5,tc6,tc7 } );
 

关联文档