Hello!
In the main form I have a multiline textbox where I can enter text. This is
named textBoxEdit.
Below I have an eventHandler for event BeginPrint called OnBeginPrint for
object PrintDocument and
an event handler for event PrintPage here called OnPrintPage for object
PrintDocument.
In the eventhandler OnBeginPrint it seems to me that these statements
surrounded with []
[int i = 0;
char[] trimParam = { '\r' };
foreach (string s in lines)
lines[i++] = s.TrimEnd(trimP aram);]
can be removed because it works just the same without them.
The purpose with these statement is to remove carrige return.
Can somebody explain why these statement which remove carrige return for
every line has no effect
on the text that is printed.
private void OnBeginPrint(ob ject sender, PrintEventArgs e)
{
char[] param = { '\n' };
lines = textBoxEdit.Tex t.Split(param);
int i = 0;
char[] trimParam = { '\r' };
foreach (string s in lines)
lines[i++] = s.TrimEnd(trimP aram);
}
private void OnPrintPage(obj ect sender, PrintPageEventA rgs e)
{
int x = 20, y = 20;
while (linesPrined < lines.Length) //antal rader att printa
{
e.Graphics.Draw String(lines[linesPrined++],
new Font("Arial", 10), Brushes.Black, x, y+=15);
if (y <= e.PageBounds.He ight - 80)
{
e.HasMorePages = true;
return;
}
}
linesPrined = 0;
e.HasMorePages = false;
}
//Tony