3
Answers

DrawArc in C# with IF statement

yamid

yamid

16y
8.3k
1
I have a problem in a c# code, and wonder if you may help me.
 
I want to draw an Arc in C# with followin codes:
First one works fine:

private void pictureBox1_Paint(object sender, PaintEventArgs e)

{

         Graphics g = e.Graphics;

         Pen pn = new Pen(Color.Blue);

         Rectangle rect = new Rectangle(50, 50, 200, 100);

         g.DrawArc(pn, rect, 12, 84);

}

 

But when I am adding the If statement to the code I cannot see any Arc on the form( there is no error in debugging  but there is a problem with showing the results):

public int m=10;

private void pictureBox1_Paint(object sender, PaintEventArgs e)

{

         if (m == 10)

            {

            Graphics g = e.Graphics;

               Pen pn = new Pen(Color.Blue);

               Rectangle rect = new Rectangle(50, 50, 200, 100);

            g.DrawArc(pn, rect, 12, 84);

            }

}

Answers (3)