如何在一个图像中保存PictureBox和TextBox?

时间:2019-02-13 16:27:47

标签: c# winforms

您好,我想将我的所有属性(pictureBox1 + pictureBox2 + ... + Textbox2)记录在一张图像中。

'Include a reference to Microsoft XML v3
Dim XMLDataDrg As DOMDocument30
Set XMLDataDrg = New DOMDocument30
XMLDataDrg.Load ("C:\...\sample.xml")

'...

Dim id As String
id = XMLDataDrg.SelectSingleNode("//Info/MC/Tool").Attributes.getNamedItem("length").Text

things to save

picture final

1 个答案:

答案 0 :(得分:0)

您可以将所有控件归为一个panel控件。在Button_Click事件中,您可以获取panel控件的高度和宽度并将其保存为图像。

Winform设计

enter image description here

按钮单击事件

private void btnSaveImage_Click(object sender, EventArgs e)
{
   int width = panel.Size.Width;
   int height = panel.Size.Height;

   Bitmap bm = new Bitmap(width, height);
   panel.DrawToBitmap(bm, new Rectangle(0, 0, width, height));

   bm.Save(@"D:\TestDrawToBitmap.png", ImageFormat.Png);
}

已保存图片

enter image description here