Spread Windows Forms 6.0 Product Documentation
GetChildDataModel Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread.Model Namespace > IChildModelSupport Interface : GetChildDataModel Method


row
Row whose child data model is to be returned
relation
Data relation name

Glossary Item Box

Gets the child data model for the specified row and data relation.

Syntax

Visual Basic (Declaration) 
Function GetChildDataModel( _
   ByVal row As Integer, _
   ByVal relation As String _
) As ISheetDataModel
Visual Basic (Usage)Copy Code
Dim instance As IChildModelSupport
Dim row As Integer
Dim relation As String
Dim value As ISheetDataModel
 
value = instance.GetChildDataModel(row, relation)
C# 
ISheetDataModel GetChildDataModel( 
   int row,
   string relation
)

Parameters

row
Row whose child data model is to be returned
relation
Data relation name

Return Value

ISheetDataModel object containing the data model

Example

This example returns the ISheetDataModel object for the specified row.
C#Copy Code
string conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source= " + Application.StartupPath + "\\Patients2000.mdb";
string sqlStr = "SELECT * FROM Patients";
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(conStr);
DataSet ds = new DataSet();
System.Data.OleDb.OleDbDataAdapter daCust = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn);
daCust.Fill(ds, "Patients");
System.Data.OleDb.OleDbDataAdapter daOrder = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn);
daOrder.Fill(ds, "Appointment");
DataRelation rel = new DataRelation("PatientRel", ds.Tables["Patients"].Columns["LName"], ds.Tables["Appointment"].Columns["LName"]);
ds.Relations.Add(rel);
fpSpread1.DataSource = ds;
FarPoint.Win.Spread.Model.IChildModelSupport cModel;
FarPoint.Win.Spread.Model.ISheetDataModel iModel;
string s;
cModel = (FarPoint.Win.Spread.Model.IChildModelSupport)fpSpread1.ActiveSheet.Models.Data;
s = cModel.GetChildRelation(0);
iModel = cModel.GetChildDataModel(0, s);
label1.Text = "The number of rows in the child model is " + iModel.RowCount.ToString();
Visual BasicCopy Code
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source= " & Application.StartupPath & "\Patients2000.mdb"
Dim sqlStr As String = "SELECT * FROM Patients"
Dim conn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(conStr)
Dim ds As DataSet = New DataSet()
Dim daCust As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(sqlStr, conn)
daCust.Fill(ds, "Patients")
Dim daOrder As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(sqlStr, conn)
daOrder.Fill(ds, "Appointment")
Dim rel = New DataRelation("PatientRel", ds.Tables("Patients").Columns("LName"), ds.Tables("Appointment").Columns("LName"))
ds.Relations.Add(rel)
FpSpread1.DataSource = ds
Dim cModel As FarPoint.Win.Spread.Model.IChildModelSupport
Dim iModel As FarPoint.Win.Spread.Model.ISheetDataModel
Dim s As String
cModel = FpSpread1.ActiveSheet.Models.Data
s = cModel.GetChildRelation(0)
iModel = cModel.GetChildDataModel(0, s)
Label1.Text = "The number of rows in the child model is " & iModel.RowCount.ToString()

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.