Gets a key for the specified row or column.
Syntax
Parameters
- index
- If UseRowIndex is true, this is the row index; otherwise, this is the column index
Return Value
Object associated with this row or column as its key
Remarks
Example
This example calls the GetKey method to return the key for the first row.
Visual Basic | Copy Code |
---|
DimdsAsNewSystem.Data.DataSet()
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
If(Me.IsPostBack)ThenReturn
CreateDataSet()
FpSpread1.Sheets(0).DataSource=ds
FpSpread1.Sheets(0).DataMember="names"
FpSpread1.Sheets(0).DataKeyField="first"
DimdmAsFarPoint.Web.Spread.Model.DefaultSheetDataModel=CType(FpSpread1.ActiveSheetView.DataModel,FarPoint.Web.Spread.Model.DefaultSheetDataModel)
ListBox1.Items.Add(dm.GetKey(0))
EndSub
PrivateSubCreateDataSet()
DimnamesAsDataTable
names=ds.Tables.Add("names")
names.Columns.Add("first")
names.Columns.Add("last")
names.Columns.Add("index")
names.Rows.Add(NewObject(){"bob","morris",0})
names.Rows.Add(NewObject(){"sean","morris",1})
names.Rows.Add(NewObject(){"chris","morris",2})
EndSub |
C# | Copy Code |
---|
System.Data.DataSetds=newSystem.Data.DataSet();
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;
CreateDataSet();
FpSpread1.Sheets[0].DataSource=ds;
FpSpread1.Sheets[0].DataMember="names";
FpSpread1.Sheets[0].DataKeyField="first";
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
ListBox1.Items.Add(dm.GetKey(0).ToString());
}
privatevoidCreateDataSet()
{
DataTablenames;
names=ds.Tables.Add("names");
names.Columns.Add("first");
names.Columns.Add("last");
names.Columns.Add("index");
names.Rows.Add(newobject[]{"bob","morris",0});
names.Rows.Add(newobject[]{"sean","morris",1});
names.Rows.Add(newobject[]{"chris","morris",2});
} |
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