Devexpress TreeList 绑定 方式 速度 优化

本文介绍了一种提高DevexrepssTreelist控件性能的方法,通过使用AppendNode逐条添加节点替代直接绑定数据源的方式,显著提升了加载速度,并提供了一段高效的实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先考虑代码中的字符串比较是否使用到 "==" 符号,该符号在string的比较中非常耗性能,如果存在则需要全部修改成 "Equal()"

按照如上修改后一般速度有显著飞跃,如果还是很卡,参照如下方法:

Devexrepss Treelist 常用绑定方式有两种

1.直接treeList.DataSource=dt;

2.使用AppendNode逐条添加

优缺点:

1.绑定方便,但是速度很慢,特别表现在最大化最小化和关闭的时候,巨卡无比

2.绑定复杂,但是速度很快,推荐使用

下面贴出速度较快的第二种参考代码:

TreeListNode parentNode = null;
TreeListNode childNode = null;

treeList.BeginUnboundLoad();
treeList.ClearNodes();

DataView treeDv = dt_F_表二费用表.DefaultView;
DataTable parentDt = null;
DataTable childDt = null;
parentDt = treeDv.ToTable();
foreach (DataRow parentDr in parentDt.Rows)
{
parentNode = this.treeList.AppendNode(new object[] { parentDr["IID"], parentDr["上级费用ID"] }, 0);

treeDv = new DataView(dt_F_表二费用表);
treeDv.RowFilter = "上级费用ID='" + parentDr["IID"].ToString() + "'";
childDt = treeDv.ToTable();
foreach (DataRow childDr in childDt.Rows)
{
childNode = this.treeList.AppendNode(new object[] { childDr["IID"], childDr["上级费用ID"] }, parentNode);
}
}

treeList.EndUnboundLoad();
treeList.ExpandAll();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值