Hi,
this is a sample code. let say I draw squares on a form

SolidBrush myBrush = new SolidBrush(Color.Red);
Graphics formGraphics = formnew.CreateGraphics();
formGraphics.FillRectangle(myBrush, new Rectangle(x1, y1, x2, y2));
myBrush.Dispose();
formGraphics.Dispose();

now question is on a given instance of a form i can draw any no of squares.But how can i erace a just drawn rectangle(same as undo). I know i should use a memory stack and a array list but don't know how to implement it.
plese give a sample code.

What came to my mind is to through a copy of the layer you draw on in the form, i.e bitmap image into ArrayList for every change through a copy into the ArrayList....
So, your ArrayList should be like that

Oldest
Older
...
Newer
Newest
You can load the bitmap at anytime with playing with ArrayList index

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.