如何将打 listBox 中的内容打印出来?谢谢了!
6 个解决方案
#1
是不是要添加什么控件,用什么方法?
#2
看gdi+部分.
#3
我是菜鸟,请多给些帮助嘛!
#4
最简单的方法,再做个浏览页,在<title></title>标签下加个<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
name="wb" VIEWASTEXT></OBJECT>利用IE进行打印
name="wb" VIEWASTEXT></OBJECT>利用IE进行打印
#5
打印按钮URL到打印页
#6
人家好像是winform的东西哈,参考一下打印数组num:
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
String printstr="";
for(int i=0;i<num.Count;i++)
{
printstr+="\n\r"+num[i].ToString();
}
// Create font and brush.
Font drawFont = new Font("Arial", 35);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
float x = 78.0F;
float y = 7.0F;
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
// Draw string to screen.
e.Graphics.DrawString(printstr, drawFont, drawBrush, x, y, drawFormat);
e.HasMorePages = false;
}
catch (Exception ex)
{
MessageBox.Show("试图预览要打印的文件时发生错误 -" + ex.Message);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
String printstr="";
for(int i=0;i<num.Count;i++)
{
printstr+="\n\r"+num[i].ToString();
}
// Create font and brush.
Font drawFont = new Font("Arial", 35);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
float x = 78.0F;
float y = 7.0F;
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
// Draw string to screen.
e.Graphics.DrawString(printstr, drawFont, drawBrush, x, y, drawFormat);
e.HasMorePages = false;
}
catch (Exception ex)
{
MessageBox.Show("试图预览要打印的文件时发生错误 -" + ex.Message);
}
}
#1
是不是要添加什么控件,用什么方法?
#2
看gdi+部分.
#3
我是菜鸟,请多给些帮助嘛!
#4
最简单的方法,再做个浏览页,在<title></title>标签下加个<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
name="wb" VIEWASTEXT></OBJECT>利用IE进行打印
name="wb" VIEWASTEXT></OBJECT>利用IE进行打印
#5
打印按钮URL到打印页
#6
人家好像是winform的东西哈,参考一下打印数组num:
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
String printstr="";
for(int i=0;i<num.Count;i++)
{
printstr+="\n\r"+num[i].ToString();
}
// Create font and brush.
Font drawFont = new Font("Arial", 35);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
float x = 78.0F;
float y = 7.0F;
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
// Draw string to screen.
e.Graphics.DrawString(printstr, drawFont, drawBrush, x, y, drawFormat);
e.HasMorePages = false;
}
catch (Exception ex)
{
MessageBox.Show("试图预览要打印的文件时发生错误 -" + ex.Message);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Print the document.
pd.Print();
}
private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
try
{
String printstr="";
for(int i=0;i<num.Count;i++)
{
printstr+="\n\r"+num[i].ToString();
}
// Create font and brush.
Font drawFont = new Font("Arial", 35);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
float x = 78.0F;
float y = 7.0F;
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
// Draw string to screen.
e.Graphics.DrawString(printstr, drawFont, drawBrush, x, y, drawFormat);
e.HasMorePages = false;
}
catch (Exception ex)
{
MessageBox.Show("试图预览要打印的文件时发生错误 -" + ex.Message);
}
}