Spread Windows Forms 12.0 Product Documentation
GetChildView Method
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > SheetView Class : GetChildView Method
Row whose child sheet is to be created
Index to the data relation collection
Creates the sheet (SheetView object) for the specified row and the specified relation index.
Syntax
'Declaration
 
Public Overridable Function GetChildView( _
   ByVal row As Integer, _
   ByVal relationIndex As Integer _
) As SheetView
'Usage
 
Dim instance As SheetView
Dim row As Integer
Dim relationIndex As Integer
Dim value As SheetView
 
value = instance.GetChildView(row, relationIndex)
public virtual SheetView GetChildView( 
   int row,
   int relationIndex
)

Parameters

row
Row whose child sheet is to be created
relationIndex
Index to the data relation collection

Return Value

SheetView object containing the child sheet
Exceptions
ExceptionDescription
Specified sheet does not support a child sheet
Specified row index is out of range; must be between 0 and the number of rows
Specified relation index is out of range; must be between 0 and the number of relations
Example
This example gets the SheetView object for the specified row and the specified relation index.
System.Data.DataSet ds = new System.Data.DataSet();
DataTable fpnames ;
DataTable fpclass;
DataTable fpgrades;

fpnames = ds.Tables.Add("Students");
fpnames.Columns.AddRange(new DataColumn[] {new DataColumn("LastName", Type.GetType("System.String")), new DataColumn("FirstName",
Type.GetType("System.String")), new DataColumn("id", Type.GetType("System.Int32"))});
fpnames.Rows.Add(new Object[] {"Jane", "Mary", 0});
fpnames.Rows.Add(new Object[] {"Rodglet", "Jonnny", 1});
fpnames.Rows.Add(new Object[] {"Steris", "Pat", 2});

fpclass = ds.Tables.Add("Class");
fpclass.Columns.AddRange(new DataColumn[] {new DataColumn("Subject", Type.GetType("System.String")), new DataColumn("owner",
Type.GetType("System.Int32")), new DataColumn("owner-subject", Type.GetType("System.String"))});

//First Student
fpclass.Rows.Add(new Object[] {"Math", 0, "0-Math"});
fpclass.Rows.Add(new Object[] {"English", 0, "0-English"});
fpclass.Rows.Add(new Object[] {"History", 0, "0-History"});
fpclass.Rows.Add(new Object[] {"Music", 0, "0-Music"});
fpclass.Rows.Add(new Object[] {"Science", 0, "0-Science"});

//Second Student
fpclass.Rows.Add(new Object[] {"Math", 1, "1-Math"});
fpclass.Rows.Add(new Object[] {"English", 1, "1-English"});
fpclass.Rows.Add(new Object[] {"History", 1, "1-History"});
fpclass.Rows.Add(new Object[] {"Music", 1, "1-Music"});
fpclass.Rows.Add(new Object[] {"Science", 1, "1-Science"});

//Third Student
fpclass.Rows.Add(new Object[] {"Math", 2, "2-Math"});
fpclass.Rows.Add(new Object[] {"English", 2, "2-English"});
fpclass.Rows.Add(new Object[] {"History", 2, "2-History"});
fpclass.Rows.Add(new Object[] {"Music", 2, "2-Music"});
fpclass.Rows.Add(new Object[] {"Science", 2, "2-Science"});

fpgrades = ds.Tables.Add("Grades");
fpgrades.Columns.AddRange(new DataColumn[] {new DataColumn("Week 1", Type.GetType("System.String")), new DataColumn("Week
2", Type.GetType("System.String")), new DataColumn("Week 3", Type.GetType("System.String")), new DataColumn("Week 4", Type.GetType("System.String")),
new DataColumn("Week 5", Type.GetType("System.String")), new DataColumn("Week 6", Type.GetType("System.String")), new DataColumn("Week
7", Type.GetType("System.String")), new DataColumn("Subject", Type.GetType("System.String")), new DataColumn("owner-subject",
Type.GetType("System.String"))});
//First Student
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Math", "0-Math"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "English", "0-English"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "History", "0-History"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Music", "0-Music"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Science", "0-Science"});

fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Math", "1-Math"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "English", "1-English"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "History", "1-History"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Music", "1-Music"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Science", "1-Science"});

fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Math", "2-Math"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "English", "2-English"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "History", "2-History"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Music", "2-Music"});
fpgrades.Rows.Add(new Object[] {"76", "80", "85", "89", "90", "93", "99", "Science", "2-Science"});

//Set the relations
ds.Relations.Add("Class", fpnames.Columns["id"], fpclass.Columns["owner"]);
ds.Relations.Add("Grades", fpclass.Columns["owner-subject"], fpgrades.Columns["owner-subject"]);
fpSpread1.ActiveSheet.DataSource = ds;
fpSpread1.ActiveSheet.DataMember = "Students";
fpSpread1.ActiveSheet.SetColumnWidth(2, 150);
fpSpread1.ActiveSheet.ExpandRow(0, true);
DialogResult dlg;
dlg = MessageBox.Show("Do you want to find the child?", "FindChildView", MessageBoxButtons.YesNo);
if (dlg == DialogResult.Yes)
{
    FarPoint.Win.Spread.SheetView ss, ss1;
    ss = fpSpread1.Sheets[0].FindChildView(0, 0);
    if (ss != null)
    {
        ss1 = ss.GetChildView(1, 0);
        if (ss1 != null)
        {
            label1.Text = ss1.Cells[0, 0].Text + " - " + ss1.Cells[0, 1].Text + " - " + ss1.Cells[0, 2].Text;
        }
    }
}
Dim ds As New System.Data.DataSet()
Dim fpnames As DataTable
Dim fpclass As DataTable
Dim fpgrades As DataTable

fpnames = ds.Tables.Add("Students")
fpnames.Columns.AddRange(New DataColumn() {New DataColumn("LastName", Type.GetType("System.String")), New DataColumn("FirstName",
Type.GetType("System.String")), New DataColumn("id", Type.GetType("System.Int32"))})
fpnames.Rows.Add(New Object() {"Jane", "Mary", 0})
fpnames.Rows.Add(New Object() {"Rodglet", "Jonnny", 1})
fpnames.Rows.Add(New Object() {"Steris", "Pat", 2})

fpclass = ds.Tables.Add("Class")
fpclass.Columns.AddRange(New DataColumn() {New DataColumn("Subject", Type.GetType("System.String")), New DataColumn("owner",
Type.GetType("System.Int32")), New DataColumn("owner-subject", Type.GetType("System.String"))})

'First Student
fpclass.Rows.Add(New Object() {"Math", 0, "0-Math"})
fpclass.Rows.Add(New Object() {"English", 0, "0-English"})
fpclass.Rows.Add(New Object() {"History", 0, "0-History"})
fpclass.Rows.Add(New Object() {"Music", 0, "0-Music"})
fpclass.Rows.Add(New Object() {"Science", 0, "0-Science"})

''Second Student
fpclass.Rows.Add(New Object() {"Math", 1, "1-Math"})
fpclass.Rows.Add(New Object() {"English", 1, "1-English"})
fpclass.Rows.Add(New Object() {"History", 1, "1-History"})
fpclass.Rows.Add(New Object() {"Music", 1, "1-Music"})
fpclass.Rows.Add(New Object() {"Science", 1, "1-Science"})

''Third Student
fpclass.Rows.Add(New Object() {"Math", 2, "2-Math"})
fpclass.Rows.Add(New Object() {"English", 2, "2-English"})
fpclass.Rows.Add(New Object() {"History", 2, "2-History"})
fpclass.Rows.Add(New Object() {"Music", 2, "2-Music"})
fpclass.Rows.Add(New Object() {"Science", 2, "2-Science"})

fpgrades = ds.Tables.Add("Grades")
fpgrades.Columns.AddRange(New DataColumn() {New DataColumn("Week 1", Type.GetType("System.String")), New DataColumn("Week
2", Type.GetType("System.String")), New DataColumn("Week 3", Type.GetType("System.String")), New DataColumn("Week 4", Type.GetType("System.String")),
New DataColumn("Week 5", Type.GetType("System.String")), New DataColumn("Week 6", Type.GetType("System.String")), New DataColumn("Week
7", Type.GetType("System.String")), New DataColumn("Subject", Type.GetType("System.String")), New DataColumn("owner-subject",
Type.GetType("System.String"))})
'First Student
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Math", "0-Math"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "English", "0-English"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "History", "0-History"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Music", "0-Music"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Science", "0-Science"})

fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Math", "1-Math"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "English", "1-English"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "History", "1-History"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Music", "1-Music"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Science", "1-Science"})

fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Math", "2-Math"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "English", "2-English"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "History", "2-History"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Music", "2-Music"})
fpgrades.Rows.Add(New Object() {"76", "80", "85", "89", "90", "93", "99", "Science", "2-Science"})

'Set the relations
ds.Relations.Add("Class", fpnames.Columns("id"), fpclass.Columns("owner"))
ds.Relations.Add("Grades", fpclass.Columns("owner-subject"), fpgrades.Columns("owner-subject"))
FpSpread1.ActiveSheet.DataSource = ds
FpSpread1.ActiveSheet.DataMember = "Students"
FpSpread1.ActiveSheet.SetColumnWidth(2, 150)
FpSpread1.ActiveSheet.ExpandRow(0, True)
Dim dlg As DialogResult
dlg = MessageBox.Show("Do you want to find the child?", "FindChildView", MessageBoxButtons.YesNo)
If dlg = DialogResult.Yes Then
    Dim ss, ss1 As FarPoint.Win.Spread.SheetView
    ss = FpSpread1.Sheets(0).FindChildView(0, 0)
    If Not ss Is Nothing Then
        ss1 = ss.GetChildView(1, 0)
        If Not ss1 Is Nothing Then
            Label1.Text = ss1.Cells(0, 0).Text & " - " & ss1.Cells(0, 1).Text & " - " & ss1.Cells(0, 2).Text
        End If
    End If
End If
See Also

Reference

SheetView Class
SheetView Members

User-Task Documentation

Working with Hierarchical Data Display
Managing Data Binding