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

Total Post:9

Points:63
Posted on    April-28-2015 11:13 PM

 .NET C# 
Ratings:


 1 Reply(s)
 515  View(s)
Rate this:
Hi
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.

Thanks.


Manoj Pandey

Total Post:26

Points:188
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)
        {
                this.Invalidate();
        }
    }

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

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

Follow MindStick