Spread for ASP.NET 8.0 Product Documentation
GetChildRelation Method (SheetView)
Example 


Relation index
Gets the name of the child data relation in a hierarchical display at the specified index.
Syntax
'Declaration
 
Public Overridable Function GetChildRelation( _
   ByVal index As Integer _
) As String
'Usage
 
Dim instance As SheetView
Dim index As Integer
Dim value As String
 
value = instance.GetChildRelation(index)
public virtual string GetChildRelation( 
   int index
)

Parameters

index
Relation index

Return Value

String containing the name of the relation
Example
This example binds the spreadsheet to a DataSet, and displays the data in a Hierarchical View. In a button click event expands the first row of the active view and returns the relationship of the first child in the view.
DataSet ds=new System.Data.DataSet();

private void Page_Load(object sender,System.EventArgs e)
{
if(this.IsPostBack)return;

this.CreateDataSet();
FpSpread1.Sheets[0].DataSource=ds;
FpSpread1.Sheets[0].DataMember="names";
FpSpread1.Sheets[0].AllowSort=true;
FpSpread1.Sheets[0].AlternatingRows[0].ForeColor=Color.Teal;
FpSpread1.Sheets[0].SetColumnWidth(2,150);
FpSpread1.RowHeader.Width=40;
FpSpread1.HierBar.ShowParentRow=true;
FpSpread1.HierBar.ShowWholePath=true;
FpSpread1.HierarchicalView=true;
}

private void CreateDataSet()
{
DataTable names;
DataTable cars;
DataTable colors;
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});
cars=ds.Tables.Add("cars");
cars.Columns.Add("make");
cars.Columns.Add("model");
cars.Columns.Add("owner");
cars.Rows.Add(Newobject[]{"ford","F-150",0});
cars.Rows.Add(Newobject[]{"ford","Mustang",1});
cars.Rows.Add(Newobject[]{"chevy","Impala",2});
colors=ds.Tables.Add("colors");
colors.Columns.Add("exterior");
colors.Columns.Add("interior");
colors.Columns.Add("owner");
colors.Rows.Add(Newobject[]{"black","gray",0});
colors.Rows.Add(Newobject[]{"red","beige",1});
colors.Rows.Add(Newobject[]{"black","tan",2});
ds.Relations.Add("cars",names.Columns["index"],cars.Columns["owner"]);
ds.Relations.Add("colors",names.Columns["index"],colors.Columns["owner"]);
}

private void Button1_Click(object sender,System.EventArgs e)
{
FarPoint.Web.Spread.SheetView sv=null;
sv=FpSpread1.ActiveSheetView;
sv.ExpandRow(0,true);
ListBox1.Items.Add(sv.GetChildRelation(0));
}
Dim ds As New System.Data.DataSet()

Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load

If(Me.IsPostBack)Then Return

CreateDataSet()
FpSpread1.Sheets(0).DataSource=ds
FpSpread1.Sheets(0).DataMember="names"
FpSpread1.Sheets(0).AllowSort=True
FpSpread1.Sheets(0).AlternatingRows(0).ForeColor=Color.Teal
FpSpread1.Sheets(0).SetColumnWidth(2,150)
FpSpread1.RowHeader.Width=40
FpSpread1.HierBar.ShowParentRow=True
FpSpread1.HierBar.ShowWholePath=True
FpSpread1.HierarchicalView=True
End Sub

Private Sub CreateDataSet()
Dim names As DataTable
Dim cars As DataTable
Dim colors As DataTable
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})
cars=ds.Tables.Add("cars")
cars.Columns.Add("make")
cars.Columns.Add("model")
cars.Columns.Add("owner")
cars.Rows.Add(NewObject(){"ford","F-150",0})
cars.Rows.Add(NewObject(){"ford","Mustang",1})
cars.Rows.Add(NewObject(){"chevy","Impala",2})
colors=ds.Tables.Add("colors")
colors.Columns.Add("exterior")
colors.Columns.Add("interior")
colors.Columns.Add("owner")
colors.Rows.Add(NewObject(){"black","gray",0})
colors.Rows.Add(NewObject(){"red","beige",1})
colors.Rows.Add(NewObject(){"black","tan",2})
ds.Relations.Add("cars",names.Columns("index"),cars.Columns("owner"))
ds.Relations.Add("colors",names.Columns("index"),colors.Columns("owner"))
End Sub

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles Button1.Click
Dim sv As FarPoint.Web.Spread.SheetView
sv=FpSpread1.ActiveSheetView
sv.ExpandRow(0,True)
ListBox1.Items.Add(sv.GetChildRelation(0))
End Sub
Requirements

Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

SheetView Class
SheetView Members

User-Task Documentation

Displaying Data as a Hierarchy

 

 


Copyright © GrapeCity, inc. All rights reserved.