WinFrom 打印问题 怎么打印ListView或者DataGirdView? 最好是有代码!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/liang4571231/archive/2008/09/29/2997943.aspx关于打印DataGirdView详细代码 private void button2_Click(object sender, EventArgs e) { PrintPreviewDialog ppd = new PrintPreviewDialog(); PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); ppd.Document = pd; ppd.ShowDialog(); } void pd_PrintPage(object sender, PrintPageEventArgs e) { // throw new Exception("The method or operation is not implemented."); // e.Graphics.MeasureString(text, ft); 测量列宽,找出最大的列宽,在一个矩形中进行打印并居中 // e.Graphics.DrwLine() ;画线 float ypos = 0; float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; //---计算每一页有多少行数据 int linePerPage = (int)(e.MarginBounds.Height / ft.GetHeight(e.Graphics)); int count = 0; int pageNo = 0; //要设全局的变量 int lineNo = pageNo * linePerPage; ypos = topMargin; while (count < linePerPage && lineNo < listview 总共有多少行 ) { ypos += ft.GetHeight(e.Graphics); e.Graphics.DrawString(“listview一行的内容” , ft, Brushes.Black, leftMargin, ypos, new StringFormat()); count++; lineNo++; } if(lineNo <listview 总共有多少行 ) e.HasMorePages =true; else e.HasMorePages =false; pageNo ++; } c# ToString 将'.'转换为了',' 的问题 怎样使winform的窗体 用户控件 类 单独编译成独立的.dll c# winform ACCESS 复制A数据库a表到B数据库b表 ? 怎样对“DataGirdView添加非绑定列”? type.InvokeMember找不到方法 ???【winform】access插入语句错误 c#中emun和string间的转换问题 using Escel 找不到类型或命名空间名称“Excel” 一个小问题 再次提问关于关键字识别的问题,请高手指点 自动更改控件大小 请假下动态添加 datagird 的模板列问题
关于打印DataGirdView详细代码
{ PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
ppd.Document = pd;
ppd.ShowDialog();
} void pd_PrintPage(object sender, PrintPageEventArgs e)
{
// throw new Exception("The method or operation is not implemented.");
// e.Graphics.MeasureString(text, ft); 测量列宽,找出最大的列宽,在一个矩形中进行打印并居中
// e.Graphics.DrwLine() ;画线
float ypos = 0;
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
//---计算每一页有多少行数据
int linePerPage = (int)(e.MarginBounds.Height / ft.GetHeight(e.Graphics));
int count = 0;
int pageNo = 0; //要设全局的变量
int lineNo = pageNo * linePerPage; ypos = topMargin;
while (count < linePerPage && lineNo < listview 总共有多少行 )
{
ypos += ft.GetHeight(e.Graphics);
e.Graphics.DrawString(“listview一行的内容” , ft, Brushes.Black, leftMargin, ypos,
new StringFormat());
count++;
lineNo++;
}
if(lineNo <listview 总共有多少行 )
e.HasMorePages =true;
else
e.HasMorePages =false;
pageNo ++;
}