C
cameljs18
private void printDocumentOrders_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
float linesPerPage = 0;
float yPosition = 1;
int count = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
oleDbConnectionOrders.Open();
OleDbCommand commandMax = new OleDbCommand("SELECT MAX
(OrderID) FROM Orders", oleDbConnectionOrders);
OleDbCommand commandMin = new OleDbCommand("SELECT MIN
(OrderID) FROM Orders", oleDbConnectionOrders);
int maxID =
int.Parse((commandMax.ExecuteScalar()).ToString());
int minID =
int.Parse((commandMin.ExecuteScalar()).ToString());
System.Collections.ArrayList mylist = new
System.Collections.ArrayList();
for (int i = minID; i <= maxID; i++)
{
OleDbCommand command1 = new OleDbCommand("SELECT SUM
(UnitPrice*Quantity) FROM [Order Details] WHERE OrderID =" +
i.ToString() + "", oleDbConnectionOrders);
string total = command1.ExecuteScalar().ToString();
mylist.Add(total);
}
foreach (string mystring in mylist)
{
Font printFont = new Font("Times New Roman", 16,
FontStyle.Bold, GraphicsUnit.Pixel);
linesPerPage = e.MarginBounds.Height /
printFont.GetHeight(e.Graphics);
if (count <= linesPerPage)
{
SolidBrush myBrush2 = new SolidBrush(Color.Black);
yPosition = topMargin + (count *
printFont.GetHeight(e.Graphics));
e.Graphics.DrawString(mystring, printFont,
myBrush2, leftMargin, yPosition, new StringFormat());
count++;
}
}
This is my code.I need to print out all the integers in the arraylist
this works for the first page.
Please tell me how to make it continue onto the next page
System.Drawing.Printing.PrintPageEventArgs e)
{
float linesPerPage = 0;
float yPosition = 1;
int count = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
oleDbConnectionOrders.Open();
OleDbCommand commandMax = new OleDbCommand("SELECT MAX
(OrderID) FROM Orders", oleDbConnectionOrders);
OleDbCommand commandMin = new OleDbCommand("SELECT MIN
(OrderID) FROM Orders", oleDbConnectionOrders);
int maxID =
int.Parse((commandMax.ExecuteScalar()).ToString());
int minID =
int.Parse((commandMin.ExecuteScalar()).ToString());
System.Collections.ArrayList mylist = new
System.Collections.ArrayList();
for (int i = minID; i <= maxID; i++)
{
OleDbCommand command1 = new OleDbCommand("SELECT SUM
(UnitPrice*Quantity) FROM [Order Details] WHERE OrderID =" +
i.ToString() + "", oleDbConnectionOrders);
string total = command1.ExecuteScalar().ToString();
mylist.Add(total);
}
foreach (string mystring in mylist)
{
Font printFont = new Font("Times New Roman", 16,
FontStyle.Bold, GraphicsUnit.Pixel);
linesPerPage = e.MarginBounds.Height /
printFont.GetHeight(e.Graphics);
if (count <= linesPerPage)
{
SolidBrush myBrush2 = new SolidBrush(Color.Black);
yPosition = topMargin + (count *
printFont.GetHeight(e.Graphics));
e.Graphics.DrawString(mystring, printFont,
myBrush2, leftMargin, yPosition, new StringFormat());
count++;
}
}
This is my code.I need to print out all the integers in the arraylist
this works for the first page.
Please tell me how to make it continue onto the next page