2012-03-28 86 views
0

我想从后面的代码中添加一列到数据绑定ASPxTreeList。我想要添加的列始终是我的表的数据字段之前的第一列。将数据绑定添加到数据绑定DevExpress ASPxTreeList

我手动设置可见索引= 0,但我的表的数据字段也有visibleIndex = 0,因此未绑定列的结果布局将显示为第二列而不是第一列。

无论如何,总是确保我添加的未绑定列总是在第一列,即使使用数据绑定ASPxTreeList?

类似的情况就像设置SettingsSelection.Enabled = true,那么复选框列将显示在第一列。

回答

0

您是否尝试过与Columns.Insert插入列:treeList.Columns.Insert(0, column)
编辑:我测试了我的解决方案,这是结论:
Columns.Insertcolumn.VisibleIndex = 0作品。
Columns.Addcolumn.VisibleIndex = 0不起作用。

protected void treeList_OnInit(object sender, EventArgs e) 
{ 
    TreeListTextColumn column = new TreeListTextColumn {Name = "Unbound", VisibleIndex = 0}; 
    // works 
    treeList.Columns.Insert(0, column); 
    // doesn't work 
    //treeList.Columns.Add(column); 
} 
+0

插入方法仅影响treelist.columncollection索引,但不影响可见索引。我刚刚计算和完成的是我使用forloop进入visibleColumn并更改其可见索引+ 1,然后指定我的未绑定列visibleIndex = 0。 感谢菲利普的建议。 – JohnZai 2012-03-28 07:52:28

+0

@JohnZai我更新了我的答案。 – Filip 2012-03-28 10:30:59