private void Printbutton_Click(object sender, EventArgs e)
        {
            PrintDocument pd = new PrintDocument();
            pd.DefaultPageSettings.Margins.Top = 10;
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
            pd.Print();            //PrintPreviewDialog cppd = new PrintPreviewDialog();
            //cppd.Document = pd;
            //cppd.ShowDialog();
        }
        void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;
            System.Drawing.Font font=new Font(this.Font,FontStyle.Regular);
            barcode.Draw(g, barcode.ClientRectangle, GraphicsUnit.Inch, 0.01f, 0,null);            g.Dispose();
        }

解决方案 »

  1.   

    我忘记原来他控件的打印是怎么做的了,应该pd.DefaultPageSettings.Margins.Top = 10;会管用吧,改个数看看到底管用不管用吧。
    我只是用他生成条形码,打印是自己做的
      

  2.   

    Bitmap memoryImage;        private void CaptureScreen()
            {
                
                Graphics myGraphics = this.CreateGraphics();
                Size s = panel1.Size;
                memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
                Graphics memoryGraphics = Graphics.FromImage(memoryImage);
                memoryGraphics.CopyFromScreen(this.Location.X+319, this.Location.Y+36, 0, 0, s);
                //memoryImage.Save(@"d:\a.bmp");
            }        private void printDocument1_PrintPage(System.Object sender,
                   System.Drawing.Printing.PrintPageEventArgs e)
            {
                Point ulCorner = new Point(0,0);
                Point urCorner = new Point(338,0);
                Point llCorner = new Point(0, 365);
                Point[] destPara = { ulCorner, urCorner, llCorner };
                e.Graphics.DrawImage(memoryImage, destPara);            //e.Graphics.DrawImage(memoryImage, 0, 0);
            }private void vistaButton1_Click(object sender, EventArgs e)
            {
    printDocument1.Print();
            }
      

  3.   

    用Barcode生成适当的条形码后...用抓图的方式,把它打印出来...觉得这样好一点...
      

  4.   

    修改为如下代码:
    Graphics g = e.Graphics;
    Rectangle rect = barcodeControl2.ClientRectangle;
    rect.X += 100;
    rect.Y += 100;
    barcodeControl2.Draw(g, rect, GraphicsUnit.Inch, 0.01f, 0, null);
    g.Dispose();因为barcodeControl2.ClientRectangle的超始位置为Point(0,0);
    所以,如果需要调整。你可以试着修改Rectangle的超始位置。