I am writing a program that loops through an array to write a report in MsWord. When a certain value is encountered I would like to insert a page break. I only want the courses of a subject code list on one page.
example of output desired:
AHS 20112
AHS 20114
BREAK
BUS 20024
BUS 20025
BUS 20154
BUS 20187
BREAK
CRJ 20006
CRJ 20009
etc...
foreach (FacultyElements F in db._DataHolder)
{
if (PreviousSubCode == string.Empty)
{
Debug.WriteLine(F.subjCode + " " + F.CRN);
}
else
{
r++;
if (PreviousSubCode == F.subjCode)
{
Debug.WriteLine(F.subjCode + " " + F.CRN);
objTable.Cell(r, 1).Range.Text = F.subjCode;
objTable.Cell(r, 2).Range.Text = F.sessCode;
objTable.Cell(r, 3).Range.Text = F.courseNum;
objTable.Cell(r, 4).Range.Text = F.seqNum;
objTable.Cell(r, 5).Range.Text = F.PtrmCode;
objTable.Cell(r, 6).Range.Text = F.CRN;
objTable.Cell(r, 7).Range.Text = F.courseTitle;
//dual fields
objTable.Cell(r, 8).Range.Text = "";
objTable.Cell(r, 9).Range.Text = "";
objTable.Cell(r, 10).Range.Text = "";
objTable.Cell(r, 11).Range.Text = F.CourseHours;
}
else
{
Debug.WriteLine("BREAK");
Debug.WriteLine(F.subjCode + " " + F.CRN);
objTable.Cell(r, 1).Range.Text = F.subjCode;
objTable.Cell(r, 2).Range.Text = F.sessCode;
objTable.Cell(r, 3).Range.Text = F.courseNum;
objTable.Cell(r, 4).Range.Text = F.seqNum;
objTable.Cell(r, 5).Range.Text = F.PtrmCode;
objTable.Cell(r, 6).Range.Text = F.CRN;
objTable.Cell(r, 7).Range.Text = F.courseTitle;
//dual fields
objTable.Cell(r, 8).Range.Text = "";
objTable.Cell(r, 9).Range.Text = "";
objTable.Cell(r, 10).Range.Text = "";
objTable.Cell(r, 11).Range.Text = F.CourseHours;
}
}
PreviousSubCode = F.subjCode;
}