哪位有WinForm版的打印代码,谢谢了

解决方案 »

  1.   

    See
    http://blog.csdn.net/pfworld/archive/2006/06/28/846975.aspx
      

  2.   

    and seehttp://blog.csdn.net/roguish/archive/2006/04/19/669475.aspx
      

  3.   

    在窗口中拖入两个打印控件:printDocument1、printDialog1
    ==============编写printDocument1的打印事件======================
    int pageNo=0;//当前正在打印的页面
    int pageMax=4;//需要打印的页面总数
    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        Font myFont = new Font("", 10, FontStyle.Regular);
        int x = 100;//横坐标
        int y = 21;//纵坐标    e.Graphics.DrawString("abc", myFont, Brushes.Black, x , y );//使用GDI+绘图
        e.Graphics.DrawString("def", myFont, Brushes.Black, x , y*2 );
        
        pageNo++;
        if (pageNo > pageMax)
            e.HasMorePages = false ;//停止打印
        else
            e.HasMorePages = true ;//换页,重新调用该方法继续打印
    }===============以下是调用方法============== DialogResult res = printDialog1.ShowDialog();
     if (res == DialogResult.OK)
         printDocument1.Print();
      

  4.   

    wxy0401(工蚁) 《-- 套打得正解
      

  5.   

    打印格式?你是指打印的字体及划线吗?
    这些只要找一下GDI+的资料就可以了,不过还是建议你用水晶报表,简单实用,学习资料也多。
      

  6.   

    我也想说得详细点,只是不知从何说起。
    打印其实就是在一张A4的纸上用GDI+画画图而已。
      

  7.   

    大家有没有打印监控代码,共享一下,谢谢了
    楼上的用e.Graphics.DrawString,e.Graphics.DrawImage去画,自己不开帖,还学会利用
      

  8.   

    [System.Runtime.InteropServices.DllImport("gdi32.dll")]
    public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
    private Bitmap memoryImage;
    private void CaptureScreen()
    {
        Graphics mygraphics = this.CreateGraphics();
        Size s = this.Size;
        memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
        Graphics memoryGraphics = Graphics.FromImage(memoryImage);
        IntPtr dc1 = mygraphics.GetHdc();
        IntPtr dc2 = memoryGraphics.GetHdc();
        BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
        mygraphics.ReleaseHdc(dc1);
        memoryGraphics.ReleaseHdc(dc2);
    }
    private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        e.Graphics.DrawImage(memoryImage, 0, 0);
    }
    private void printButton_Click(System.Object sender, System.EventArgs e)
    {
        CaptureScreen();
        printDocument1.Print();
    }
      

  9.   

    http://www.codeproject.com/dotnet/PrintingFormReport.asp