MESCIUS SPREAD for ASP.NET 10.0J
GetChildRelation メソッド (SheetView)

リレーションインデックス
階層表示内の、指定したインデックスにある子データ リレーションの名前を取得します。
構文
'Declaration
 
Public Overridable Function GetChildRelation( _
   ByVal index As Integer _
) As String
public virtual string GetChildRelation( 
   int index
)

パラメータ

index
リレーションインデックス

戻り値の型

リレーションの名前を含むString
この例では、スプレッドシートをDataSetに連結し、階層ビューにデータを表示します。ボタンクリックイベントで、アクティブビューの先頭行を展開し、ビュー内の最初の子のリレーションを返します。
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(new object[]{"bob", "morris", 0});
    names.Rows.Add(new object[]{"sean", "morris", 1});
    names.Rows.Add(new object[]{"chris", "morris", 2});
    
    cars = ds.Tables.Add("cars");
    cars.Columns.Add("make");
    cars.Columns.Add("model");
    cars.Columns.Add("owner");
    cars.Rows.Add(new object[]{"ford", "F-150", 0});
    cars.Rows.Add(new object[]{"ford", "Mustang", 1});
    cars.Rows.Add(new object[]{"chevy", "Impala", 2});
    
    colors = ds.Tables.Add("colors");
    colors.Columns.Add("exterior");
    colors.Columns.Add("interior");
    colors.Columns.Add("owner");
    colors.Rows.Add(new object[]{"black", "gray", 0});
    colors.Rows.Add(new object[]{"red", "beige", 1});
    colors.Rows.Add(new object[]{"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.SheetViewsv = null;
    sv = FpSpread1.ActiveSheetView;
    sv.ExpandRow(0, true);
    ListBox1.Items.Add(sv.GetChildRelation(0));
}
Private ds As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If IsPostBack Then Return
	
	Me.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(New Object() {"bob", "morris", 0})
    names.Rows.Add(New Object() {"sean", "morris", 1})
    names.Rows.Add(New Object() {"chris", "morris", 2})

    cars = ds.Tables.Add("cars")
    cars.Columns.Add("make")
    cars.Columns.Add("model")
    cars.Columns.Add("owner")
    cars.Rows.Add(New Object() {"ford", "F-150", 0})
    cars.Rows.Add(New Object() {"ford", "Mustang", 1})
    cars.Rows.Add(New Object() {"chevy", "Impala", 2})

    colors = ds.Tables.Add("colors")
    colors.Columns.Add("exterior")
    colors.Columns.Add("interior")
    colors.Columns.Add("owner")
    colors.Rows.Add(New Object() {"black", "gray", 0})
    colors.Rows.Add(New Object() {"red", "beige", 1})
    colors.Rows.Add(New Object() {"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
参照

SheetView クラス
SheetView メンバ

開発者の手引き

データの階層表示

 

 


© MESCIUS inc. All rights reserved.