Gets the number of the child data relations for a hierarchical display of data.
Syntax
Visual Basic (Declaration) | |
---|
Public ReadOnly Property ChildRelationCount As Integer |
C# | |
---|
public int ChildRelationCount {get;} |
Property Value
Integer number of child relations
Example
This example creates a DefaultSheetDataModel and assigns it to the DataModel of the spreadsheet. The data source of the model is attached to some DataTables and the ParentRelationName and ParentRowIndex are returned to a list box.
Visual Basic | Copy Code |
---|
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
If(IsPostBack)ThenReturn
DimdsAsNewSystem.Data.DataSet()
DimdmAsNewFarPoint.Web.Spread.Model.DefaultSheetDataModel()
FpSpread1.ActiveSheetView.DataModel=dm
FpSpread1.HierarchicalView=True
DimempAsDataTable=NewDataTable("Employee")
DimdeptAsDataTable=NewDataTable("Department")
DimlnameAsDataColumn=NewDataColumn("LastName",GetType(System.String))
DimfnameAsDataColumn=NewDataColumn("FirstName",GetType(System.String))
DimdnameAsDataColumn=NewDataColumn("DeptName",GetType(System.String))
DimareaAsDataColumn=NewDataColumn("Area",GetType(System.String))
DimidAsDataColumn=emp.Columns.Add("ID",GetType(System.Int32))
id.AutoIncrement=True
DimprimarykeyAsDataColumn()=NewDataColumn(){id}
emp.PrimaryKey=primarykey
emp.Columns.Add(lname)
emp.Columns.Add(fname)
id=dept.Columns.Add("ID",GetType(System.Int32))
id.AutoIncrement=True
dept.PrimaryKey=NewDataColumn(){id}
id.AutoIncrement=True
DimlangAsDataColumn=dept.Columns.Add("Language",GetType(System.Int32))
DimforeignkeyAsDataColumn()=NewDataColumn(){lang}
dept.Columns.Add(dname)
dept.Columns.Add(area)
ds.Tables.Add(emp)
ds.Tables.Add(dept)
DimtiAsDataRow=emp.NewRow()
ti(lname)="Bazemoreland"
ti(fname)="Ti"
emp.Rows.Add(ti)
DimginnyAsDataRow=emp.NewRow()
ginny(lname)="Danielson"
ginny(fname)="Ginny"
emp.Rows.Add(ginny)
DimbobAsDataRow=emp.NewRow()
bob(lname)="Morrison"
bob(fname)="Bob"
emp.Rows.Add(bob)
DimrelAsDataRelation=NewDataRelation("FarPoint",primarykey,foreignkey,False)
ds.Relations.Add(rel)
DimrowAsDataRow=dept.NewRow()
row("Language")=ti("ID")
row(dname)="TechSupport"
row(area)="C#"
dept.Rows.Add(row)
row=dept.NewRow()
row("Language")=ginny("ID")
row(dname)="TechSupport"
row(area)="VB.Net"
dept.Rows.Add(row)
row=dept.NewRow()
row("Language")=bob("ID")
row(dname)="TechSupport"
row(area)="C#"
dept.Rows.Add(row)
ds.AcceptChanges()
dm.DataSource=ds
dm.DataMember="Employee"
Dimdm2AsFarPoint.Web.Spread.Model.DefaultSheetDataModel
dm2=FpSpread1.Sheets(0).GetChildView(0,0).DataModel
ListBox1.Items.Add(dm2.ParentRelationName)
ListBox1.Items.Add(dm2.ParentRowIndex)
ListBox1.Items.Add(dm.ChildRelationCount)
EndSub |
C# | Copy Code |
---|
privatevoidPage_Load(objectsender,System.EventArgse)
{
System.Data.DataSetds=newSystem.Data.DataSet();
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm;
dm=newFarPoint.Web.Spread.Model.DefaultSheetDataModel();
FpSpread1.ActiveSheetView.DataModel=dm;
FpSpread1.HierarchicalView=true;
DataTableemp=newDataTable("Employee");
DataTabledept=newDataTable("Department");
DataColumnlname=newDataColumn("LastName",typeof(String));
DataColumnfname=newDataColumn("FirstName",typeof(String));
DataColumndname=newDataColumn("DeptName",typeof(String));
DataColumnarea=newDataColumn("Area",typeof(String));
DataColumnid=emp.Columns.Add("ID",typeof(Int32));
id.AutoIncrement=true;
emp.PrimaryKey=newDataColumn[]{id};
emp.Columns.Add(lname);
emp.Columns.Add(fname);
id=dept.Columns.Add("ID",typeof(Int32));
id.AutoIncrement=true;
dept.PrimaryKey=newDataColumn[]{id};
id.AutoIncrement=true;
DataColumnlang=dept.Columns.Add("Language",typeof(Int32));
DataColumn[]foreignkey=newDataColumn[]{lang};
dept.Columns.Add(dname);
dept.Columns.Add(area);
ds.Tables.Add(emp);
ds.Tables.Add(dept);
DataRowti=emp.NewRow();
ti[lname]="Bazemoreland";
ti[fname]="Ti";
emp.Rows.Add(ti);
DataRowginny=emp.NewRow();
ginny[lname]="Danielson";
ginny[fname]="Ginny";
emp.Rows.Add(ginny);
DataRowbob=emp.NewRow();
bob[lname]="Morrison";
bob[fname]="Bob";
emp.Rows.Add(bob);
DataRelationrel=newDataRelation("FarPoint",emp.PrimaryKey,foreignkey,false);
ds.Relations.Add(rel);
DataRowrow=dept.NewRow();
row["Language"]=ti["ID"];
row[dname]="TechSupport";
row[area]="C#";
dept.Rows.Add(row);
row=dept.NewRow();
row["Language"]=ginny["ID"];
row[dname]="TechSupport";
row[area]="VB.Net";
dept.Rows.Add(row);
row=dept.NewRow();
row["Language"]=bob["ID"];
row[dname]="TechSupport";
row[area]="C#";
dept.Rows.Add(row);
ds.AcceptChanges();
dm.DataSource=ds;
dm.DataMember="Employee";
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm2;
dm2=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets[0].GetChildView(0,0).DataModel;
ListBox1.Items.Add(dm2.ParentRelationName);
ListBox1.Items.Add(Convert.ToString(dm2.ParentRowIndex));
ListBox1.Items.Add(Convert.ToString(dm.ChildRelationCount));
} |
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