C# Windows form Control to Image?

后端 未结 7 1260
遇见更好的自我
遇见更好的自我 2020-12-18 08:29

I am trying to create an image of a Panel and save it to a folder. The problem is the panel has scrollbars and the image generated is only for the visible portion of the Pan

相关标签:
7条回答
  • 2020-12-18 09:35

    Hmmm... It sounds like (as you did not say so in the original question) but would you have a picturebox acting as a container inside the panel's container i.e. nested containers?

    Have you not considered doing this:

    // Assume pic is the type of PictureBox and the image property is assigned
    PictureBox pic;
    
    // And that the picturebox is embedded in the Panel variable p.
    p.Controls.Add(pic);
    
    // ...
    
    // So why not do this?
    pic.Image.Save(...); 
    

    The Save method of the Image class has 5 overloads so choose one at your convenience.

    Hope this helps, Best regards, Tom.

    0 讨论(0)
提交回复
热议问题