日期:2014-05-17  浏览次数:20901 次

关于打印winform窗口的问题,求助
在winform界面上添加了个groupBox1,如下图


然后按打印预览,却出现这样


代码如下

 public partial class print : Form
    {
        public print()
        {
            InitializeComponent();
            this.printDocument1.OriginAtMargins = true;//启用页边距
            this.pageSetupDialog1.EnableMetric = true; //以毫米为单位


        }

        private void button3_Click(object sender, EventArgs e)   //打印设置
        {
            this.pageSetupDialog1.ShowDialog(); 

        }

        private void button2_Click(object sender, EventArgs e)   //打印
        {
            if (this.printDialog1.ShowDialog() == DialogResult.OK)
            {
                this.printDocument1.Print();
            }

        }

        private void button1_Click(object sender, EventArgs e)   //打印预览
        {
            printDialog1.Document = printDocument1;
            this.printPreviewDialog1.ShowDialog();
            
            
       
        }

        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {

            ////打印内容 为 整个Form
            //Image myFormImage;
            //myFormImage = new Bitmap(this.Width, this.Height);
            //Graphics g = Graphics.FromImage(myFormImage);
            //g.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, this.Size);
            //e.Graphics.DrawImage(myFormImage, 0, 0);

            //打印内容 为 局部的 this.groupBox1
  &nbs