c# winform 的GraphicsPath一个类怎么用,我画的路径怎么显示不出来??

来源:百度知道 编辑:UC知道 时间:2024/05/18 06:14:23
请问我错在哪里了,该怎么改

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

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(10, 10, 50, 10);
myPath.StartFigure();
myPath.AddArc(rect, 0, 180);
//myPath.AddArc(
myPath.CloseFigure();

// Draw the path to screen.
e.Graphics.DrawPath(new Pen(Color.Red, 10), myPath);

把你程序里的这一段放到form的Paint事件里,运行就OK了