I'm trying to draw a line on the form in C#.
When i place the below draw line code in Form1_Load() method it does not draw the line when application starts. But if the same code is placed in Form1_Paint() method it works.
System.Drawing. Pen myPen = new System.Drawing. Pen(System.Draw ing.Color.Red, 5);
System.Drawing. Graphics formGraphics = this.CreateGrap hics();
formGraphics.Dr awLine(myPen, 10, 10, 150, 200);
Why does the code not work in Form_Load(). Is is required that all graphics code needs to be executed in Form_Paint() method only?
When i place the below draw line code in Form1_Load() method it does not draw the line when application starts. But if the same code is placed in Form1_Paint() method it works.
System.Drawing. Pen myPen = new System.Drawing. Pen(System.Draw ing.Color.Red, 5);
System.Drawing. Graphics formGraphics = this.CreateGrap hics();
formGraphics.Dr awLine(myPen, 10, 10, 150, 200);
Why does the code not work in Form_Load(). Is is required that all graphics code needs to be executed in Form_Paint() method only?
Comment