j.mcgurk

j.mcgurk

  • NA
  • 1
  • 0

PaintEventHandler Question

Sep 23 2003 12:36 PM
I am new to the c# language and I have a question. My graphics code looks like this: private void DrawLinesPoint(object sender,PaintEventArgs e) { SBO2_3.arcDeg = 180; Rectangle rect = new Rectangle( 0, 0, 500, 400); Pen myPen = new Pen(Color.Red, 5); Graphics g = this.CreateGraphics(); g.DrawEllipse(myPen, 125, 30, 20, 50); g.DrawEllipse(myPen, 325, 30, 20, 50); g.DrawArc(myPen, rect, 0, arcDeg); g.DrawString("SampleText", new Font("Arial", 20, FontStyle.Bold), Brushes.Red, 165, 165); } And I call it on a menu click : private void menu_selGraphics_Click(object sender, System.EventArgs e) { this.Paint += new PaintEventHandler(DrawLinesPoint); } If I do anything else in the program, then the selGraphics button does nothing. If I select the button before I do anything else it works. Please let me know what I have missed. Also, how can I get g.DrawString to print a string variable set withing the program? Thank you in advance.