Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a user control on my project. But it seems that the paint event handler has some problems when it comes to creating a line. After creating a line, I scroll down the user control. Then it create several lines. What should I do?
Posted

1 solution

Add this code in the first line in paint event
e.Graphics.Clear(Color.White);
 
Share this answer
 
v2
Comments
yummy02 2-Jan-11 21:27pm    
I'd tried that one, but it did not work. The images in my pictureboxes disappear.
jerrykid 2-Jan-11 21:30pm    
So...what things did you do in paint event?
jerrykid 2-Jan-11 21:35pm    
Can you post your full codes in paint event function?
yummy02 2-Jan-11 21:50pm    
this is my code in paint event:

Graphics g = e.Graphics;
Pen myPen = new Pen(System.Drawing.Color.Red, 5);
g.DrawLine(myPen, pbox.Right, pbox.Bottom, 0, 0);
jerrykid 2-Jan-11 22:08pm    
Is this all codes in paint event? Is this code in paint event of pbox_Paint(object sender, PaintEventArgs e)?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900