Hiya
I bought the book "Beginning Visual C# 2005", and have gotten up to the "Simple Text Editer" under Using Common Dialogs. I have made it fully and it works perfectly except when I try to print a very long line of text it prints the first part then cuts off the rest of the line at the page boundry.
Code:
private void OnPrintPage(object sender, PrintPageEventArgs e)
{
int x = e.MarginBounds.Left;
int y = e.MarginBounds.Top;
while (linesPrinted < lines.Length)
{
e.Graphics.DrawString(lines[linesPrinted++], textBoxEdit.Font,
Brushes.Black, x, y);
y += textBoxEdit.Font.Height;
if (y >= e.MarginBounds.Bottom)
{
e.HasMorePages = true;
return;
}
}
linesPrinted = 0;
e.HasMorePages = false;
}
private void OnBeginPrint(object sender, PrintEventArgs e)
{
char[] param = { '\n' };
if (dlgPrint.PrinterSettings.PrintRange == PrintRange.Selection)
{
lines = textBoxEdit.SelectedText.Split(param);
}
else
{
lines = textBoxEdit.Text.Split(param);
}
int i = 0;
char[] trimParam = { '\r' };
foreach (string s in lines)
{
lines[i++] = s.TrimEnd(trimParam);
}
}
private void OnEndPrint(object sender, PrintEventArgs e)
{
lines = null;
}
I have no idea how to stop this from happening, could you please help me.
Whether you think you can or think you can't, you're probably right.