C#打印问题

wojiushid5 2013-03-27 03:58:10

C#如上页面,点击打印按钮怎么将页面以表格形式打印出来,点打印预览按钮,以表格形式预览出来??textbox内容调取数据库。求详细代码!
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
by_封爱 版主 2013-03-27
  • 打赏
  • 举报
回复

System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();
p.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(p_PrintPage);
p.Print();





 void p_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            foreach (Control item in groupBox1.Controls)
            {
                if (item is Label)
                {
                    Label l = item as Label;
                    e.Graphics.DrawString(l.Text, l.Font, new SolidBrush(l.ForeColor), l.Location);//此处自行修改..
                }
            }
        }
gxingmin 2013-03-27
  • 打赏
  • 举报
回复
你得在printDocument里自己打印输出 给你个例子参考一下 http://www.cnblogs.com/zhcw/archive/2011/11/30/2269083.html

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧