0

我在表单上有几个标签和一个 datagrid 控件,我想在 c# 中从这些控件中打印数据

    private void CaptureScreen()
    {
        Graphics myGraphics = printPanel.CreateGraphics();
        Size s = printPanel.Size;
        memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
        Graphics memoryGraphics = Graphics.FromImage(memoryImage);
        Point screenLoc = PointToScreen(printPanel.Location); // Get the location of the Panel in Screen Coordinates
        memoryGraphics.CopyFromScreen(screenLoc.X, screenLoc.Y, 0, 0, s);
    }

    private void printDocument1_PrintPage(System.Object sender,
           System.Drawing.Printing.PrintPageEventArgs e)
    {
        e.Graphics.DrawImage(memoryImage, 0, 0);
    }
4

1 回答 1

0

客户端

<asp:Button ID="printButton" runat="server" Text="Print" OnClientClick="javascript:window.print();" />

服务器端

 ClientScript.RegisterStartupScript(this.GetType(),"PrintOperation","printing()",true);

javascript

function printing()
        {
            window.print();


        }
于 2013-05-24T11:11:16.450 回答