打印整个面板

时间:2013-08-29 08:23:07

标签: c# winforms panel

我有这个界面

enter image description here

我想在第一个标签中打印所有数据(第一个标签有一个包含所有labelstexboxes的停靠面板),包括图片。

我用过

    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);
        }
   }

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

1 个答案:

答案 0 :(得分:0)

如果您想对控件进行'打印屏幕',可以使用Control.DrawToBitmap()