Type | Description | |||
IUnboundHandler | An object that implements the IUnboundHandler interface. |
If the VirtualMode property is True and the DataSource property is set ( not empty ), the control provides an internal object that implements the IUnboundHandler interface to provide data for the control from the data source.
The following VB sample shows how to implement the IUnboundHandler interface:
Option Explicit Implements IUnboundHandler Private Sub Form_Load() With Grid1 .BeginUpdate .FullRowSelect = False ' Adds two columns With .Columns Dim i As Long For i = 0 To 1 With .Add("Column " & i + 1).Editor .EditType = EditTypeEnum.EditType End With Next End With Set .UnboundHandler = Me .EndUpdate End With End Sub Private Property Get IUnboundHandler_ItemsCount(ByVal Source As Object) As Long ' The control requires the number of items. the Set .UnboundHandler = Me invokes the IUnboundHandler_ItemsCount method IUnboundHandler_ItemsCount = 16 End Property Private Sub IUnboundHandler_ReadItem(ByVal Index As Long, ByVal Source As Object, ByVal ItemHandle As Long) ' The control requires an item With Grid1.Items .CellValue(ItemHandle, 0) = Index .CellValue(ItemHandle, 1) = Index + 1 End With End Sub
Running the UnboundMode in VFP 7.0 or greater
define class UnboundHandler as custom implements IUnboundHandler in "ExGrid.dll" function IUnboundHandler_get_ItemsCount(Source) return 10000000 && we are going to have that many virtual items endfunc function IUnboundHandler_ReadItem(Index, Source, ItemHandle) With Source.Items .DefaultItem = ItemHandle .CellValue(0, 0) = 'Virtual Item ' + transform(Index+1) && in this example, just set text in Column 0 EndWith endfunc enddefine
with thisform.Grid1 .Columns.Add("Column 0") .UnboundHandler = newobject('UnboundHandler', 'class1.prg') endwith
function IUnboundHandler_get_ItemsCount(Source) return reccount('MyCursor') endfunc function IUnboundHandler_ReadItem(Index, Source, ItemHandle) select MyCursor go Index+1 With Source.Items .DefaultItem = ItemHandle .CellValue(0, 0) = 'Virtual Item ' + MyCursor.Field1 EndWith endfunc enddefine
Please check also the VirtualMode property that includes multiple samples. The setup program installs a sample VC\UnboundMode, for C++ version.