Spread的虚拟模式Virtual Mode

虚拟模式在数据网格如Spread中实现类似自动分页的功能,有效提高加载大量数据的速度。通常设置Virtual Max为1000000,Max Virtual Rows为100,Rows Per Read为20。开启后,避免使用`spread.datarowcnt`获取最大行数,因为其在虚拟模式下可能返回0。代码开启虚拟模式时,设置`virtualmaxrows`为-1或1000000。注意,手动修改`virtualmaxrows`为特定值后无法保存,可能是软件bug。此外,开启特殊滚动条时,禁用Home和End键,否则可能导致系统崩溃。

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

虚拟模式也就相当于自动分页,将大量数据分次读取,不用一次性全部装入表格,如果数据量大的话,速度可以得到明显的提升,尤其是spread本身装数据就比datagrid等慢。

在设计器中直接打开比较方便,一般情况下,我将Virtual Max,Max Virtual Rows,Rows Per Read三个参数分别设1000000,100,20。

设置完成后,记的一定不用再使用spread.datarowcnt来提取最大行,因为我习惯于使用 spread.maxrow=spread.datarowcnt来删除多余的行。但开启virtual mode后,这个值取出来总是0。

然后如果用代码来开启,可以这样

' Set the number of rows or records in the data source
'
 Use -1 when the number of records is unknown
fpSpread1.VirtualMaxRows = 1000000
' Set the max number of rows or records to keep in memory
fpSpread1.VirtualOverlap = 100
' Set the number of rows or records to read when additional data is requested
fpSpread1.VirtualRows = 10
' Enable virtual mode
fpSpread1.VirtualMode = True
' Reflect the number of rows in the virtual buffer and not the max number of rows or records
fpSpread1.VirtualScrollBuffer = True
' Enable special virtual scroll bars
fpSpread1.VScrollSpecial = True
fpSpread1.VScrollSpecialType
=VScrollSpecialNoPageUpDown 

在使用过程中,我发现如果将virtualmaxrows手工设成一个值后,再改回-1时总是保存不住,不知道算不算一个BUG。而1000000是缺省值,应该等同于-1。

还有一个问题,如果打开了特殊的滚动条后,一定不要打开home和end两个按钮,反正在我用的时候,一但按完end,再按home键,机子立刻死翘翘。事实上,如果有上千条记录,也不可能去来回翻看,滚动条也是可有可无的东西了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值