REMOVE LINES AT RUNTIME

Jaya J

Total Post:9

Points:63
Posted by  Jaya J
C# 
 733  View(s)
Ratings:
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.
  1. Manoj Pandey

    Post:26

    Points:188
    Re: Remove Lines at runtime

     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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!