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;
}
}
}