Gets whether the GetKey method generates a key for a row.
Syntax
Visual Basic (Declaration) | |
---|
Public ReadOnly Property UseRowIndex As Boolean |
C# | |
---|
public bool UseRowIndex {get;} |
Property Value
Boolean:
true if the GetKey method takes the row index as the parameter;
false if the GetKey method takes the column index as parameter
Remarks
Example
This example displays a list of products in the spread. The GetKey method returns the name of the product.
Visual Basic | Copy Code |
---|
<Serializable()>_
PublicClassOrderItem
DimidAsInteger
DimqtyAsInteger
DimonameAsString
DimopriceAsDouble
PublicSubNew(ByValproductIDAsInteger,ByValnameAsString,ByValpriceAsDouble,ByValquantityAsInteger)
Me.id=productID
Me.qty=quantity
Me.oname=name
Me.oprice=price
EndSub
PublicReadOnlyPropertyProductID()AsInteger
Get
Returnid
EndGet
EndProperty
PublicPropertyQuantity()AsInteger
Get
Returnqty
EndGet
Set(ByValValueAsInteger)
qty=Value
EndSet
EndProperty
PublicReadOnlyPropertyName()AsString
Get
Returnoname
EndGet
EndProperty
PublicReadOnlyPropertyPrice()AsDouble
Get
Returnoprice
EndGet
EndProperty
EndClass
<Serializable()>_
PublicClassOrderList
InheritsFarPoint.Web.Spread.Model.BaseSheetDataModel
ImplementsFarPoint.Web.Spread.Model.IDataSourceSupport
PrivateordersAsArrayList=NewArrayList()
PublicReadOnlyPropertyUseRowIndex()AsBooleanImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.UseRowIndex
Get
ReturnFalse
EndGet
EndProperty
PublicFunctionGetKey(ByValindexAsInteger)AsObjectImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetKey
DimoiAsOrderItem=orders(index)
Returnoi.Name
EndFunction
PublicOverridesPropertyRowCount()AsInteger
Get
Return3
EndGet
Set(ByValValueAsInteger)
EndSet
EndProperty
PublicOverridesPropertyColumnCount()AsInteger
Get
Returnorders.Count
EndGet
Set(ByValValueAsInteger)
EndSet
EndProperty
PublicOverridesFunctionGetValue(ByValrAsInteger,ByValcAsInteger)AsObject
If(r=0)Then
DimoiAsOrderItem=orders(c)
Returnoi.Quantity
ElseIf(r=1)Then
DimoiAsOrderItem=orders(c)
Returnoi.name
ElseIf(r=2)Then
DimoiAsOrderItem=orders(c)
Returnoi.price
EndIf
Return""
EndFunction
PublicFunctionGetColumnName(ByValcolAsInteger)AsString
ReturnNothing
EndFunction
PublicReadOnlyPropertyItem(ByValnameAsString)
Get
DimelemsAsIEnumerator=orders.GetEnumerator()
While(elems.MoveNext())
DimeAsOrderItem=elems.Current
If(e.Name=name)Then
ReturnItem
EndIf
EndWhile
ReturnNothing
EndGet
EndProperty
PublicSubAdd(ByValvalueAsOrderItem)
If(Me.Item(value.Name)=Nothing)Then
orders.Add(value)
Else
DimoIAsOrderItem=Me.Item(value.Name)
oI.Quantity=oI.Quantity+1
EndIf
EndSub
PublicSubClearCart()
orders.Clear()
EndSub
PublicPropertyDataSource()AsObjectImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.DataSource
Get
ReturnNothing
EndGet
Set(ByValValueAsObject)
EndSet
EndProperty
PublicPropertyDataMember()AsStringImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.DataMember
Get
ReturnNothing
EndGet
Set(ByValValueAsString)
EndSet
EndProperty
PublicPropertyDataKeyField()AsObjectImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.DataKeyField
Get
ReturnNothing
EndGet
Set(ByValValueAsObject)
EndSet
EndProperty
PublicFunctionGetDataColumnName(ByValcolumnAsInteger)AsStringImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetDataColumnName
ReturnString.Empty
EndFunction
PublicPropertyParentRowIndex()AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.ParentRowIndex
Get
Return0
EndGet
Set(ByValValueAsInteger)
EndSet
EndProperty
PublicPropertyParentRelationName()AsStringImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.ParentRelationName
Get
ReturnNothing
EndGet
Set(ByValValueAsString)
EndSet
EndProperty
PublicReadOnlyPropertyChildRelationCount()AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.ChildRelationCount
Get
Return0
EndGet
EndProperty
PublicPropertyParent()AsFarPoint.Web.Spread.Model.IDataSourceSupportImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.Parent
Get
ReturnNothing
EndGet
Set(ByValValueAsFarPoint.Web.Spread.Model.IDataSourceSupport)
EndSet
EndProperty
PublicFunctionGetChildRelation(ByValindexAsInteger)AsStringImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetChildRelation
ReturnNothing
EndFunction
PublicFunctionGetDataView(ByValcreateAsBoolean)AsDataViewImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetDataView
ReturnNothing
EndFunction
PublicSubSetModelDataColumn(ByValcolumnAsInteger,ByValnameAsString)ImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.SetModelDataColumn
EndSub
PublicFunctionGetDataRowFromModelRow(ByValrowAsInteger)AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetDataRowFromModelRow
Return0
EndFunction
PublicFunctionGetModelRowFromDataRow(ByValrowAsInteger)AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetModelRowFromDataRow
Return0
EndFunction
PublicFunctionGetDataColumnFromModelColumn(ByValcolumnAsInteger)AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetDataColumnFromModelColumn
Return0
EndFunction
PublicFunctionGetModelColumnFromDataColumn(ByValcolumnAsInteger)AsIntegerImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetModelColumnFromDataColumn
Return0
EndFunction
PublicFunctionIsColumnBound(ByValcolumnAsInteger)AsBooleanImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.IsColumnBound
ReturnFalse
EndFunction
PublicPropertyAutoGenerateColumns()AsBooleanImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.AutoGenerateColumns
Get
ReturnFalse
EndGet
Set(ByValValueAsBoolean)
EndSet
EndProperty
PublicFunctionIsColumnBound(ByValrowAsInteger,ByValrelationAsString)AsBoolean
ReturnNothing
EndFunction
PublicFunctionGetChildDataModel(ByValrowAsInteger,ByValrelationAsString)AsFarPoint.Web.Spread.Model.ISheetDataModelImplementsFarPoint.Web.Spread.Model.IDataSourceSupport.GetChildDataModel
ReturnNothing
EndFunction
EndClass
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
If(Me.IsPostBack)ThenReturn
DimDataAsOrderList=NewOrderList()
Data.Add(NewOrderItem(1,"P1",10.0,10))
Data.Add(NewOrderItem(2,"P2",20.0,5))
Data.Add(NewOrderItem(3,"P3",30.0,1))
FpSpread1.ActiveSheetView.DataModel=Data
ListBox1.Items.Add(Data.GetKey(1).ToString())
EndSub |
C# | Copy Code |
---|
[Serializable()]
publicclassOrderItem
{
publicintproductID;
publicintquantity;
publicStringname;
publicdoubleprice;
publicOrderItem(intproductID,Stringnames,doubleprice,intquantity)
{
this.productID=productID;
this.quantity=quantity;
this.name=name;
this.price=price;
}
publicintProductID
{
get{returnproductID;}
}
publicintQuantity
{
get{returnquantity;}
set{quantity=value;}
}
publicStringName
{
get{returnname;}
}
publicdoublePrice
{
get{returnprice;}
}
}
[Serializable()]
publicclassOrderList:FarPoint.Web.Spread.Model.BaseSheetDataModel,FarPoint.Web.Spread.Model.IDataSourceSupport
{
privateArrayListorders=newArrayList();
publicboolUseRowIndex
{
get{returnfalse;}
}
publicobjectGetKey(intindex)
{
OrderItemoi=(OrderItem)orders[index];
returnoi.Name;
}
publicoverrideintRowCount
{
get{return3;}
}
publicoverrideintColumnCount
{
get{returnorders.Count;}
}
publicoverrideobjectGetValue(intr,intc)
{
switch(r)
{
case0:
//Qty
OrderItemoi=(OrderItem)orders[c];
returnoi.Quantity;
case1:
//Name
oi=(OrderItem)orders[c];
returnoi.Name;
case2:
//Price
oi=(OrderItem)orders[c];
returnoi.Price;
}
return"";
}
publicstringGetColumnName(intcol)
{
returnnull;
}
publicOrderItemthis[Stringname]
{
get
{
IEnumeratoritems=orders.GetEnumerator();
while(items.MoveNext())
{
OrderItemitem=(OrderItem)items.Current;
if(item.Name==name)returnitem;
}
returnnull;
}
}
publicvoidAdd(OrderItemvalue)
{
if(this[value.Name]==null)
{
orders.Add(value);
}
else
{
OrderItemoI=(OrderItem)this[value.Name];
oI.Quantity=oI.Quantity+1;
}
}
publicvoidClearCart()
{
orders.Clear();
}
publicobjectDataSource
{
get
{
returnnull;
}
set{}
}
publicstringDataMember
{
get
{
returnnull;
}
set{}
}
publicobjectDataKeyField
{
get
{
returnnull;
}
set{}
}
publicstringGetDataColumnName(intcolumn){returnnull;}
publicintParentRowIndex
{
get
{
return0;
}
set{}
}
publicstringParentRelationName
{
get
{
returnnull;
}
set{}
}
publicintChildRelationCount{get{return0;}}
publicFarPoint.Web.Spread.Model.IDataSourceSupportParent
{
get
{
returnnull;
}
set{}
}
publicstringGetChildRelation(intindex){returnnull;}
publicDataViewGetDataView(boolcreate){returnnull;}
publicvoidSetModelDataColumn(intcolumn,stringcolumnName){}
publicintGetDataRowFromModelRow(introw){return-1;}
publicintGetModelRowFromDataRow(introw){return-1;}
publicintGetDataColumnFromModelColumn(intcolumn){return-1;}
publicintGetModelColumnFromDataColumn(intcolumn){return-1;}
publicboolIsColumnBound(intcolumn){returnfalse;}
publicboolAutoGenerateColumns{get{returnfalse;}set{}}
publicFarPoint.Web.Spread.Model.ISheetDataModelGetChildDataModel(introw,stringrelation){returnnull;}
}
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;
OrderListdata=newOrderList();
data.Add(newOrderItem(1,"P1",10.0,10));
data.Add(newOrderItem(2,"P2",20.0,5));
data.Add(newOrderItem(3,"P3",30.0,1));
FpSpread1.ActiveSheetView.DataModel=data;
ListBox1.Items.Add(data.GetKey(1).ToString());
} |
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also