Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 打印整个面板_C#_Winforms_Panel - Fatal编程技术网

C# 打印整个面板

C# 打印整个面板,c#,winforms,panel,C#,Winforms,Panel,我有这个接口 我想打印第一个选项卡中的所有数据第一个选项卡有一个停靠面板,其中包含所有标签和文本框,包括图片 我用过 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { if (tabControl1.SelectedIndex == 0) { string data =

我有这个接口

我想打印第一个选项卡中的所有数据第一个选项卡有一个停靠面板,其中包含所有标签和文本框,包括图片

我用过

    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        if (tabControl1.SelectedIndex == 0)
        {   
            string data = "Title : \t" + cmbTitle.Text + "\n\nFirst Name : \t" + txtFirstName.Text + "\n\nLast Name : \t" + txtLastName.Text + "\n\nMiddle Name : \t" + txtMiddleName.Text + "\n\nFull Name : \t" + txtFullName.Text + "\n\nNick Name : \t" +
                txtNick.Text + "\n\nGender : \t" + cmbGender.Text + "\n\nCountry : \t" + cmbHomeCountry.Text + "\n\nState : \t" + txtState.Text + "\n\nEmail Address : " + txtEmail.Text;
            Image img = resizeImage(pictureBox1.Image, new Size(300, 300));
            e.Graphics.DrawString("Personal Data for " + txtFullName.Text, new Font("Lucida Calligraphy", 20, FontStyle.Regular), Brushes.Black, 5, 5);
            e.Graphics.DrawImage(img, 5, 70);
            e.Graphics.DrawString(data, new Font("MS Reference Sans Serif", 20, FontStyle.Bold), Brushes.Black, 5, 420);
        }
   }

这很有效,但我想知道是否有更好的方法来打印整个面板。

如果您想对可以使用的控件进行“打印屏幕”