disappear lines  
Author Message
ashk1860





PostPosted: Visual C# General, disappear lines Top

hi

my application get functions and draw the diagram of that function. I use Garaphic class and drawLine method to do it and every thing seems OK. but if any other window comes in front, then the lines will disappear.

what's the problem and what should I do



Visual C#19  
 
 
swemaniac





PostPosted: Visual C# General, disappear lines Top

The problem is that you're only drawing the lines ONCE. Whenever another area covers your graphics, it's gone.

The solution to this is to put your drawing code into you form's OnPaint() method so that it is drawn whenever the form needs to be redrawn, as when another window gets in the way.

OnPaint is a base method so you need to override it like this:


protected ovveride void OnPaint(PaintEventArgs e)
{
   
// let Windows paint everything that needs repainting
    base.OnPaint(e);

    // your drawing goes here, use e.Graphics
}



Cheers


 
 
ashk1860





PostPosted: Visual C# General, disappear lines Top

yes

that works great

best regards