如何把DataGridView中的内容 在一张纸上 打印两遍 如何把DataGridView中的内容 在一张纸上 打印两遍放在excel里面也行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 提取DataGridView中的数据,生成一个DataTable,然后打印DataTable打印DataTable的方法http://blog.csdn.net/pfworld/archive/2006/06/28/846975.aspx 两种方法1\使用excel,将数据导入excel,用oExcel.ActiveWindow.SelectedSheets._PrintOut(oMissing, oMissing, 1, true, oMissing, oMissing, 1); 2\使用printDocument直接打印//执行打印窗体中的数据操作private void toolStripButton2_Click(object sender, EventArgs e) { printDialog1.ShowDialog(); //设置打印文档 printPreviewDialog1.Document = this.printDocument1; printPreviewDialog1.ShowDialog(); }//在窗体中绘制要打印的数据private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e) { //e.Graphics.DrawString(dataGridView1.Columns.ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, 260, 400); int r = 0; int c = 20; for(int i=0;i<dt.Rows.Count;i++) { for(int j=0;j<dt.Columns.Count;j++) { e.Graphics.DrawString(dt.Rows[i][j].ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, r, c); r = r + 60; } r = 0; c += 20; } } 如何根据内容自动调整窗体大小 可作为DLL加载的exe程序怎么变得? VS2005中C#如何设置对话框的位置? 关于获取前一天时间的问题 图片强制类型转换问题 高手留步:静态变量的并发使用问题 .net的老大哥们请帮帮小弟,多谢了! 如何用c#和sql做课程管理系统啊。。 各位:帮忙看看,万分着急!!!!!!!!!!!1111 imagelist问题。高分求解答 怎么让窗体里设计成这样?新手救急啊~~ 缓存问题 VaryByCustom= "browser"
打印DataTable的方法
http://blog.csdn.net/pfworld/archive/2006/06/28/846975.aspx
1\使用excel,将数据导入excel,用oExcel.ActiveWindow.SelectedSheets._PrintOut(oMissing, oMissing, 1, true, oMissing, oMissing, 1);
2\使用printDocument直接打印
//执行打印窗体中的数据操作private void toolStripButton2_Click(object sender, EventArgs e)
{ printDialog1.ShowDialog(); //设置打印文档
printPreviewDialog1.Document = this.printDocument1;
printPreviewDialog1.ShowDialog();
}//在窗体中绘制要打印的数据private void printDocument1_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e)
{
//e.Graphics.DrawString(dataGridView1.Columns.ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, 260, 400);
int r = 0;
int c = 20;
for(int i=0;i<dt.Rows.Count;i++)
{
for(int j=0;j<dt.Columns.Count;j++)
{
e.Graphics.DrawString(dt.Rows[i][j].ToString(), new Font("宋体", 10, FontStyle.Regular), Brushes.Black, r, c);
r = r + 60;
}
r = 0;
c += 20;
}
}