C# WinForm 技巧:控件截图

Point screenPoint = 控件.PointToScreen(new Point());
Rectangle rect = new Rectangle(screenPoint, chartCellLine.Size);
Image img = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(img);
g.CopyFromScreen(rect.X - 1, rect.Y - 1, 0, 0, rect.Size);
img.Save(strPicPath, System.Drawing.Imaging.ImageFormat.Jpeg);

//截图窗体上任意位置的控件

 

posted @ 2016-04-14 14:27  山治先生  阅读(2620)  评论(0编辑  收藏  举报