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

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 萝卜青菜 阅读(286) 评论(1) 编辑 收藏

评论

#1楼  回复 引用 查看   

web form中怎么搞呢,知道不,web控件没有DrawToBitmap的
2010-06-06 21:01 | yush      

导航

<2006年7月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

公告

昵称:萝卜青菜
园龄:6年3个月
粉丝:0
关注:0

搜索

 
 

常用链接

随笔分类(55)

文章分类(3)

积分与排名

  • 积分 - 0
  • 排名 - 67422

最新评论

推荐排行榜