还原FlowLayoutPanel的先前图像

时间:2019-05-02 19:28:16

标签: c# windows winforms paint

我正在尝试使用Windows窗体创建简单的绘画应用程序。目前,我正在尝试对上一个屏幕执行撤消操作(在屏幕上创建最后一个图形之前)。我发现可以使用Bitmap存储FlowLayoutPanel的当前内容(正在完成绘制):

Bitmap panel = new Bitmap(this.Width, this.Height); // this refers to Form1 class object
Graphics.FromImage(panel).CopyFromScreen(this.Left, this.Top, 0, 0, this.Size);

不幸的是,我无法重新创建面板,因此存储在变量panel中的面板将被带回正在运行的应用程序中的FlowLayoutPanel,这是我尝试的方法:

this.BackgroundImage = panel; // this refers to Form1 class object

我将感谢您的提示。

0 个答案:

没有答案