Spread Windows Forms 10.0 Product Documentation
FindChildView Method
Example 


Row index of the related sheet
Relation index
Gets the child view for this sheet with the specified name.
Syntax
'Declaration
 
Public Overridable Function FindChildView( _
   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.FindChildView(row, relationIndex)
public virtual SheetView FindChildView( 
   int row,
   int relationIndex
)

Parameters

row
Row index of the related sheet
relationIndex
Relation index

Return Value

SheetView object containing the child sheet
Example
This example finds the child view at the specified location.
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
        End If
    End If
End If
End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SheetView Class
SheetView Members

User-Task Documentation

Working with Hierarchical Data Display

 

 


Copyright © GrapeCity, inc. All rights reserved.