C# How can I delete things which I drew with GDI+
HI
How can I delete things which I drew with GDI, I mean for instance, a rectangle.
It is killing me, I have tried every thing and I've got nothing. I can do it with Graphics.Clear(SomeColor) because it will mess up my background, I want just get rid of things that I drew.
I’m using following code to draw rectangle:
Graphics gfx = this.tabControlPanel3.CreateGraphics();
Rectangle rc = new Rectangle(10,20,100,200);
gfx.SmoothingMode = SmoothingMode.AntiAlias;
Pen pen = new Pen(Brushes.Red,3);
gfx.DrawRectangle(pen,rc);
I want to delete this rectangle from my Form after pressing a button.
Please help me, I can’t sleep because of it :)))))