Winform下richtextbox截图实现

 1  #region 根据richtextbox创建GDI+
 2         private void DrawGDI(RichTextBox rich,Panel panl,PictureBox p2)
 3         {
 4             rich.Update();
 5             Bitmap bmp = new Bitmap(rich.Width, rich.Height);
 6             using (Graphics gr = Graphics.FromImage(bmp))
 7             {
 8                 gr.CopyFromScreen(rich.PointToScreen(Point.Empty), Point.Empty, rich.Size);
 9             }
10             p2.Image = bmp;
11             panl.Controls.Remove(rich);
12             panl.Controls.Add(p2);
13             panl.Update();          
14         }
15         #endregion

 

你可能感兴趣的:(WinForm)