yamid

yamid

  • NA
  • 98
  • 0

why using the conditional statement with Paint event does not work fine?

Sep 1 2008 11:22 AM

Dear all,

I have a code to draw an arc which works fine, but when I am using a conditional statement like IF with that , there is no error but I cannot see the Arc on the form

please look at these two codes , one of them with "If " statement and another without:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace _1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_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);

 

}

}

}

 

 

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace _1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

public int m;

private void Form1_Paint(object sender, PaintEventArgs e)

{

if (m == 1)

{

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 (1)