Home > DeveloperSection > Forums > Remove Lines at runtime
Jaya J
Jaya J

Total Post:9

Posted on    April-28-2015 11:13 PM

 .NET C# 

 1 Reply(s)
 713  View(s)
Rate this:
I.m drawing number of lines at runtime in windows form application using Pen.Now I want to remove some of the lines by clicking MouseRight button at runtime.Is it possible?.If possible then tell me the code using c#.Please help me anyone.


Manoj Pandey

Total Post:26

Posted on    April-29-2015 2:29 AM

 The Graphics.Draw... functions replace the pixels. There is no way to undo that unless you either

  1. store the pixels that are being changed so you can reverse the drawing or
  2. draw the pixels on a copy of the desktop so you can revert to the actual desktop or
  3. overlay the desktop with a transparent surface and draw on that and remove the surface            when it is no longer  needed.
You can use  Invalidate(); method for reset your lines

private void button1_MouseDown(object sender, MouseEventArgs e)
        if (e.Button == MouseButtons.Left)
        if (e.Button == MouseButtons.Right)

Modified On Apr-29-2015 02:31:46 AM

Don't want to miss updates? Please click the below button!

Follow MindStick