音效模擬模式也就相當於自動分頁,將大量資料分次讀取,不用一次性全部裝入表格,如果資料量大的話,速度可以得到明顯的提升,尤其是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鍵,機子立刻死翹翹。事實上,如果有上千條記錄,也不可能去來回翻看,捲軸也是可有可無的東西了。