<Serializable()>_
PublicClassOrderItem
Dim id As Integer
Dim qty As Integer
Dim oname As String
Dim oprice As Double
Public Sub New(ByVal productID As Integer,ByVal name As String,ByVal price As Double,ByVal quantity As Integer)
Me.id=productID
Me.qty=quantity
Me.oname=name
Me.oprice=price
EndSub
Public ReadOnly Property ProductID() As Integer
Get
Return id
End Get
End Property
Public Property Quantity() As Integer
Get
Return qty
End Get
Set(ByVal Value As Integer)
qty=Value
End Set
End Property
Public ReadOnly Property Name() As String
Get
Return oname
End Get
End Property
Public ReadOnly Property Price() As Double
Get
Return oprice
End Get
End Property
End Class
<Serializable()>_
PublicClassOrderList
Inherits FarPoint.Web.Spread.Model.BaseSheetDataModel
Implements FarPoint.Web.Spread.Model.IDataSourceSupport
Private orders As ArrayList = New ArrayList()
Public ReadOnly Property UseRowIndex() As Boolean Implements FarPoint.Web.Spread.Model.IDataSourceSupport.UseRowIndex
Get
Return False
End Get
End Property
Public Function GetKey(ByVal index As Integer) As Object Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetKey
Dim oi As OrderItem=orders(index)
Return oi.Name
End Function
Public Overrides Property RowCount() As Integer
Get
Return 3
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Overrides Property ColumnCount() As Integer
Get
Return orders.Count
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Overrides Function GetValue(ByVal r As Integer,ByVal c As Integer)As Object
If(r=0)Then
Dim oi As OrderItem=orders(c)
Return oi.Quantity
ElseIf(r=1)Then
Dim oi As OrderItem=orders(c)
Return oi.name
ElseIf(r=2)Then
Dim oi As OrderItem=orders(c)
Return oi.price
End If
Return""
End Function
Public Function GetColumnName(ByVal col As Integer)As String
Return Nothing
End Function
Public ReadOnly Property Item(ByVal name As String)
Get
Dim elems As IEnumerator=orders.GetEnumerator()
While(elems.MoveNext())
Dim e As OrderItem=elems.Current
If(e.Name=name)Then
Return Item
End If
End While
Return Nothing
End Get
End Property
Public Sub Add(ByVal value As OrderItem)
If(Me.Item(value.Name)=Nothing)Then
orders.Add(value)
Else
Dim oI As OrderItem=Me.Item(value.Name)
oI.Quantity=oI.Quantity+1
End If
End Sub
Public Sub ClearCart()
orders.Clear()
End Sub
Public Property DataSource() As Object Implements FarPoint.Web.Spread.Model.IDataSourceSupport.DataSource
Get
Return Nothing
End Get
Set(ByVal Value As Object)
End Set
End Property
Public Property DataMember() As String Implements FarPoint.Web.Spread.Model.IDataSourceSupport.DataMember
Get
Return Nothing
End Get
Set(ByVal Value As String)
End Set
End Property
Public Property DataKeyField() As Object Implements FarPoint.Web.Spread.Model.IDataSourceSupport.DataKeyField
Get
Return Nothing
End Get
Set(ByVal Value As Object)
End Set
End Property
Public Function GetDataColumnName(ByVal column As Integer)As String Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetDataColumnName
Return String.Empty
End Function
Public Property ParentRowIndex() As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.ParentRowIndex
Get
Return 0
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Property ParentRelationName() As String Implements FarPoint.Web.Spread.Model.IDataSourceSupport.ParentRelationName
Get
Return Nothing
End Get
Set(ByVal Value As String)
End Set
End Property
Public ReadOnly Property ChildRelationCount() As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.ChildRelationCount
Get
Return 0
End Get
End Property
Public Property Parent() As FarPoint.Web.Spread.Model.IDataSourceSupport Implements FarPoint.Web.Spread.Model.IDataSourceSupport.Parent
Get
Return Nothing
End Get
Set(ByVal Value As FarPoint.Web.Spread.Model.IDataSourceSupport)
End Set
End Property
Public Function GetChildRelation(ByVal index As Integer)As String Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetChildRelation
Return Nothing
End Function
Public Function GetDataView(ByVal create As Boolean)As DataView Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetDataView
Return Nothing
End Function
Public Sub SetModelDataColumn(ByVal column As Integer,ByVal name As String)Implements FarPoint.Web.Spread.Model.IDataSourceSupport.SetModelDataColumn
End Sub
Public Function GetDataRowFromModelRow(ByVal row As Integer)As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetDataRowFromModelRow
Return 0
End Function
Public Function GetModelRowFromDataRow(ByVal row As Integer)As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetModelRowFromDataRow
Return 0
End Function
Public Function GetDataColumnFromModelColumn(ByVal column As Integer)As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetDataColumnFromModelColumn
Return 0
End Function
Public Function GetModelColumnFromDataColumn(ByVal column As Integer)As Integer Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetModelColumnFromDataColumn
Return 0
End Function
Public Function IsColumnBound(ByVal column As Integer)As Boolean Implements FarPoint.Web.Spread.Model.IDataSourceSupport.IsColumnBound
Return False
End Function
Public Property AutoGenerateColumns()As Boolean Implements FarPoint.Web.Spread.Model.IDataSourceSupport.AutoGenerateColumns
Get
Return False
End Get
Set(ByVal Value As Boolean)
End Set
End Property
Public Function IsColumnBound(ByVal row As Integer,ByVal relation As String)As Boolean
Return Nothing
End Function
Public Function GetChildDataModel(ByVal row As Integer,ByVal relation As String)As FarPoint.Web.Spread.Model.ISheetDataModel Implements FarPoint.Web.Spread.Model.IDataSourceSupport.GetChildDataModel
Return Nothing
End Function
End Class
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
If(Me.IsPostBack)Then Return
Dim Data As OrderList = New OrderList()
Data.Add(New OrderItem(1,"P1",10.0,10))
Data.Add(New OrderItem(2,"P2",20.0,5))
Data.Add(New OrderItem(3,"P3",30.0,1))
FpSpread1.ActiveSheetView.DataModel=Data
ListBox1.Items.Add(Data.GetKey(1).ToString())
EndSub