麻烦高手帮我看下,谢谢
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){
int x = e.MarginBounds.Left;
int y = e.MarginBounds.Top;
lines = this.richTextBox.Text.Split(param);
while (linesPrinted < lines.length)
{
e.Graphics.DrawString(lines[linesPrinted++],
new Font("Arial", 10), Brushes.Black, x, y);
y += 15;
if (y >= e.PageBounds.Height - 80)
{
e.HasMorePages = true;
return;
}
}
linesPrinted = 0;
e.HasMorePages = false;
}
错误 1 当前上下文中不存在名称“lines” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 22 13 打印
错误 2 当前上下文中不存在名称“param” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 22 49 打印
错误 3 当前上下文中不存在名称“linesPrinted” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 23 20 打印
错误 4 当前上下文中不存在名称“lines” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 23 35 打印
错误 5 当前上下文中不存在名称“lines” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 25 39 打印
错误 6 当前上下文中不存在名称“linesPrinted” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 25 45 打印
错误 7 当前上下文中不存在名称“linesPrinted” C:\Users\dell\Documents\Visual Studio 2008\Projects\控件练习\打印\Form1.cs 34 13 打印
--------------------编程问答-------------------- 代码不全,抄的不够完美,丢了 lines 之类的很东西 --------------------编程问答-------------------- richTextBox 找个你窗体上的文本框,其他的如下试试
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)--------------------编程问答--------------------
{
int x = e.MarginBounds.Left;
int y = e.MarginBounds.Top;
string[] lines = this.richTextBox.Text.Split('\n');
int linesPrinted = 0;
while (linesPrinted < lines.Length)
{
e.Graphics.DrawString(lines[linesPrinted++],
new Font("Arial", 10), Brushes.Black, x, y);
y += 15;
if (y >= e.PageBounds.Height - 80)
{
e.HasMorePages = true;
return;
}
}
linesPrinted = 0;
e.HasMorePages = false;
}
--------------------编程问答-------------------- 代码是复制的吧?
变量声明没复制过来
string[] lines,
int linesPrinted
抄都不会,没救了
补充:.NET技术 , C#