Christian L

Christian L

  • NA
  • 1
  • 0

Calling Form1_Paint method

Dec 23 2009 9:12 AM

I want to be able to draw an Ellipse at any point on a pictureBox that I click on.  The problem is calling up the method that has the code to draw the ellipse.  Thanks for your help in advance.


public
partial class Form1 : Form
{
Graphics graphics;
string XStr, YStr;
Pen blackPen = new Pen(Color.Black, 3);
Rectangle rect = new Rectangle(200, 200, 200, 100);

public Form1()
{
InitializeComponent();
pictureBox1.MouseUp +=
new MouseEventHandler(OnMouseup);
}
public void Form1_Load(object sender, EventArgs e)
{


}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen blackPen = new Pen(Color.Black, 3);
Rectangle rect = new Rectangle(200, 200, 200, 100);
e.Graphics.DrawEllipse(blackPen, rect);

}
private void pictureBox1_Click(object sender, EventArgs e)
{

}
public void OnMouseup(object sender,MouseEventArgs e)
{

graphics.DrawEllipse(blackPen, 10, 10, 20, 10);
/*
* XStr = Convert.ToString(e.X);
YStr = Convert.ToString(e.Y);
textBox1.Text = (XStr);
textBox2.Text = (YStr);
*/

}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}

Answers (2)