ultragrid 虚表及延迟加载

2014年8月5日

Private Sub FrmUltraDataSource1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.UltraDataSource1.Band.Columns.Clear()
Me.UltraDataSource1.Band.Columns.Add(“Index”, GetType(Integer))
Dim i As Integer
For i = 0 To 9
Me.UltraDataSource1.Band.Columns.Add(“Col” & i, GetType(String))
Next

‘ Set the row count. This is how many rows we will have.
Me.UltraDataSource1.Rows.SetCount(1000000)

‘ Disable any data modifications.
Me.UltraDataSource1.AllowAdd = False
Me.UltraDataSource1.AllowDelete = False
Me.UltraDataSource1.ReadOnly = True

‘ Set the LoadStyle to LoadOnDemand so the UltraGrid doesn’t pre-load
‘ all the rows. LoadOnDemand load style creates rows as they are needed
‘ (for example when they are scrolled into view). You must do this
‘ before setting the DataSource on the UltraGrid.

Me.UltraGrid1.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand
Me.UltraGrid1.DataSource = Me.UltraDataSource1

‘ Disable sorting. If not disabled, when the user sorts rows, UltraGrid
‘ will create all the rows.
Me.UltraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select
End Sub

Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
‘ Set the scroll style to immediate so the rows get scrolled immediately
‘ when the vertical scrollbar thumb is dragged.

e.Layout.ScrollStyle = ScrollStyle.Immediate

‘ ScrollBounds of ScrollToFill will prevent the user from scrolling the
‘ grid further down once the last row becomes fully visible.

e.Layout.ScrollBounds = ScrollBounds.ScrollToFill
End Sub

Private Sub BtnTitle_MouseUp(ByVal o As Object, ByVal e As MouseEventArgs) Handles btnTitle.MouseUp
DirectCast(Me.Owner, frmMain).Navigation(e.Button)
End Sub

Private Sub UltraDataSource1_CellDataRequested(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinDataSource.CellDataRequestedEventArgs) Handles UltraDataSource1.CellDataRequested

If 0 = e.Column.Index Then
‘ 0th column is the Index column. This is how we added columns in
‘ when we setup the data source.
e.Data = e.Row.Index
Else
e.Data = e.Row.Index & “, ” & e.Column.Index
End If

‘ By default UltraDataSource will cache the provided cell value and not ask for
‘ it next time it’s needed. Set CacheData to false to prevent UltraDataSource
‘ from doing so.
e.CacheData = False

End Sub

 

启用延迟加载时,排序或求和等操作会造成延迟失败。

声明: 本文采用 BY-NC-SA 协议进行授权. 转载请注明转自: ultragrid 虚表及延迟加载
本文的评论功能被关闭了.