请问我错在哪里了,该怎么改using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace WindowsApplication1
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
//this.Click += new EventHandler(Form6_Click);
//this.DoubleClick += new EventHandler(Form6_DoubleClick);
} private void Form6_Load(object sender, EventArgs e)
{
PaintEventArgs ex=new PaintEventArgs(this.CreateGraphics(),new Rectangle(0,0,this.Width,this.Height));
AddArcExample(ex); }
private void AddArcExample(PaintEventArgs e)
{
MessageBox.Show(e.Graphics.ToString());
// Create a GraphicsPath object.
GraphicsPath myPath = new GraphicsPath(); // Set up and call AddArc, and close the figure.
Rectangle rect = new Rectangle(20, 20, 50, 100);
myPath.StartFigure();
myPath.AddArc(rect, 0, 180);
myPath.CloseFigure(); // Draw the path to screen.
e.Graphics.DrawPath(new Pen(Color.Red, 10), myPath);
this.Refresh();
}
private void Form6_Click(object sender, EventArgs e)
{
// MessageBox.Show("单击事件触发");
} private void Form6_DoubleClick(object sender, EventArgs e)
{
// MessageBox.Show("双击事件触发");
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace WindowsApplication1
{
public partial class Form6 : Form
{
public Form6()
{
InitializeComponent();
//this.Click += new EventHandler(Form6_Click);
//this.DoubleClick += new EventHandler(Form6_DoubleClick);
} private void Form6_Load(object sender, EventArgs e)
{
PaintEventArgs ex=new PaintEventArgs(this.CreateGraphics(),new Rectangle(0,0,this.Width,this.Height));
AddArcExample(ex); }
private void AddArcExample(PaintEventArgs e)
{
MessageBox.Show(e.Graphics.ToString());
// Create a GraphicsPath object.
GraphicsPath myPath = new GraphicsPath(); // Set up and call AddArc, and close the figure.
Rectangle rect = new Rectangle(20, 20, 50, 100);
myPath.StartFigure();
myPath.AddArc(rect, 0, 180);
myPath.CloseFigure(); // Draw the path to screen.
e.Graphics.DrawPath(new Pen(Color.Red, 10), myPath);
this.Refresh();
}
private void Form6_Click(object sender, EventArgs e)
{
// MessageBox.Show("单击事件触发");
} private void Form6_DoubleClick(object sender, EventArgs e)
{
// MessageBox.Show("双击事件触发");
}
}
}
private void AddArcExample(PaintEventArgs e)
{
GraphicsPath myPath = new GraphicsPath(); Rectangle rect = new Rectangle(20, 20, 50, 100);
myPath.StartFigure();
myPath.AddArc(rect, 0, 180);
myPath.CloseFigure(); e.Graphics.DrawPath(new Pen(Color.Red, 10), myPath);
} private void Form1_Paint(object sender, PaintEventArgs e)
{
AddArcExample(e);
}Load的时候窗体还没有显示出来,窗体显示会重新绘制。