将窗体或窗体上某控件保存为图片

void SaveControlImage(Control c, string file)
{
  
int w = c.Size.Width;
  
int h = c.Size.Height;
  
using (Bitmap bmp = new Bitmap(w, h)) {
    c.DrawToBitmap(bmp, 
new Rectangle(00, w, h));
    bmp.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
  }
}
哈哈哈~ 超级简单,但是很多时候搞个窗体截图用得到:)

posted on 2006-07-22 17:02  萝卜青菜  阅读(535)  评论(1编辑  收藏  举报

导航