home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2001-09-09 | 5.3 KB | 163 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "CGridDataSource"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- '-----------------------------------------------------------------------------
- ' This is a part of the BeeGrid ActiveX control.
- ' Copyright ⌐ 2000 Stinga
- ' All rights reserved.
- '
- ' You have a right to use and distribute the BeeGrid sample files in original
- ' form or modified, provided that you agree that Stinga has no warranty,
- ' obligations, or liability for any sample application files.
- '-----------------------------------------------------------------------------
- Option Explicit
-
- Implements IsgGridDataSource
-
- ' Array that is used as a data store
- Private Const maxRowCount = 110
- Public mRowCount As Long
- Private mColCount As Long
- Private arrData() As String
-
-
- Private Sub Class_Initialize()
-
- ' Initialize data array
- mRowCount = 64
- mColCount = 6
- ReDim arrData(0 To maxRowCount - 1, 0 To mColCount - 1)
- Dim i As Long
- For i = 0 To mRowCount - 1
- arrData(i, 0) = i
- arrData(i, 1) = i Mod 8
- Next
- End Sub
-
- '------------------------------------------------------------------------------
- ' IsgGridDataSource implementation
- '------------------------------------------------------------------------------
- Private Function IsgGridDataSource_AddRow(ByVal RowIndex As Long, _
- ByVal ColCount As Long, _
- ByVal RowData As Variant) As Boolean
-
- ' The AddRow function is called by the BeeGrid control when it needs to
- ' add a new row to the data source. This function should return True
- ' if the new row has been added to the data store.
- '
- ' Parameters:
- ' RowIndex - not used in this version
- ' ColCount - number of elements in the RowData array
- ' RowData - array of variants with row data
-
- If mRowCount < maxRowCount Then
- ' Add new row
- mRowCount = mRowCount + 1
-
- ' Copy given data to the internal buffer
- Dim col As Long
- For col = 0 To ColCount - 1
- arrData(mRowCount - 1, col) = RowData(col)
- Next
-
- ' Row has been added
- IsgGridDataSource_AddRow = True
- Else
- ' Row limit is reached
- IsgGridDataSource_AddRow = False
- End If
- End Function
-
- Private Function IsgGridDataSource_DeleteRow(ByVal RowIndex As Long) As Boolean
-
- ' The DeleteRow function is called by the BeeGrid control when it needs
- ' to delete a row from the data source. This function should return True
- ' if a row has been deleted from to the data store.
- '
- ' Parameters:
- ' RowIndex - data index of the row to be deleted
-
- If (RowIndex >= 0) And (RowIndex < mRowCount) Then
-
- ' Shift rows below deleted one
- Dim row As Long, col As Long
- For row = RowIndex + 1 To mRowCount - 1
- Dim colUBound
- colUBound = UBound(arrData, 2)
- For col = 0 To colUBound
- arrData(row - 1, col) = arrData(row, col)
- Next
- Next
-
- ' Decrese row count
- mRowCount = mRowCount - 1
-
- ' Row has been deleted
- IsgGridDataSource_DeleteRow = True
- Else
- ' Can not delete any more rows
- IsgGridDataSource_DeleteRow = False
- End If
- End Function
-
- Private Function IsgGridDataSource_GetRowCount() As Long
-
- ' The GetRowCount function is called by the BeeGrid control when it needs
- ' to know exact row count. This function should return current row count.
-
- IsgGridDataSource_GetRowCount = mRowCount
- Debug.Print mRowCount
- End Function
-
- Private Sub IsgGridDataSource_GetRowData(ByVal RowIndex As Long, _
- ByVal ColCount As Long, _
- RowData As Variant)
-
- ' The GetRowData subroutine is called by the BeeGrid control when it
- ' needs data from a particular row. This function should initialize
- ' RowData parameter with array of variants. Each variant in that
- ' array represents data for one row cell.
- '
- ' Parameters:
- ' RowIndex - index of the requested row
- ' ColCount - number of elements in the RowData array
- ' RowData - array of variants with row data. This array
- ' has ColCount elements and is resized by the
- ' caller (BeeGrid control).
-
- Dim col&
- For col = 0 To ColCount - 1
- RowData(col) = arrData(RowIndex, col)
- Next
- End Sub
-
- Private Sub IsgGridDataSource_SetRowData(ByVal RowIndex As Long, _
- ByVal ColCount As Long, _
- ByVal RowData As Variant)
-
- ' The SetRowData subroutine is called by the BeeGrid control when it
- ' needs to update row data.
- '
- ' Parameters:
- ' RowIndex - index of the row that is being updated
- ' ColCount - number of elements in the RowData array
- ' RowData - array of variants with row data.
-
- Dim col&
- For col = 0 To ColCount - 1
- arrData(RowIndex, col) = RowData(col)
- Next
- End Sub
-
-
-