本示例演示了在窗体上绘制曲线的多种不同方法。示例
  复制代码 
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Black);// Draw head with an ellipse.
formGraphics.DrawEllipse(myPen, 0, 0, 200, 200);// Draw winking eye with an arc.
formGraphics.DrawArc(myPen, 40, 40, 40, 40, 180, -180);// Draw open eye with an ellipse.
formGraphics.DrawEllipse(myPen, 120, 40, 40, 40);// Draw nose with a Bezier spline.
formGraphics.DrawBezier(myPen, 100, 60, 120, 100, 90, 120, 80, 100);// Draw mouth with a canonical spline.
Point[] apt = new Point[4];
apt[0] = new Point(60, 140);
apt[1] = new Point(140, 140);
apt[2] = new Point(100, 180);
apt[3] = new Point(60, 140);
formGraphics.DrawCurve(myPen, apt, 0, 3, 0.9f);myPen.Dispose();
formGraphics.Dispose();
 编译代码
此示例需要:一个 Windows 窗体应用程序项目,其中带有一个名为 formGraphics 的窗体。此代码必须处于 Form 类的范围内。该窗体的实例由 this 表示。
============================================================================================
问一下这个窗体怎么添加

解决方案 »

  1.   

    刚才那个帖子结贴太快了,没有弄明白如何从form重新派生出一个类,导致这个例子也不会做
      

  2.   

    既然是WinForm窗体应用程序,你添加个Windows窗体,然后命名为formGraphics.cs不就产生了一个名为formGraphics 的窗体了。this就代表该窗体,假如该窗体中有一个ID为Label1的控件,那么通过this.Label1就表示是该Label控件
      

  3.   

    GDI+绘图,要放在OnPaint方法或Paint事件中...至于为什么,你需要了解Windows窗体模型原理...建议你从基础学起,别想一口吃成胖子...先去看看GDI是什么吧...Windows GDI
      

  4.   

    我刚刚也是按你说的方法改了一下窗体的名字,然后在窗体的属性对话框中添加了一个form_click事件,把代码加在里面运行成功了。现在想问的是::如何新创建一个窗口,保留默认的form1,
    用类似于Form1 formGraphics=new Form1();   这样的方式来创建。
      

  5.   

    ... 我是告诉你放Paint事件中。你应该再去看下。
      

  6.   


    那如何创建一个Paint事件呢,我在窗体的属性中没找到
      

  7.   

    sorry,我二了,我找到Paint事件了
      

  8.   

    http://topic.csdn.net/u/20111108/22/3c5dadd5-7f4b-4c2d-9d54-bad448019d27.html?1245795190
    链接在这里,我对你最开始的回复有点不太明白,我想知道怎么通过你最初描述的方法来实现绘图,而不是通过事件
      

  9.   

    Form1 form=new Form1();是这句误导你了么?我只是说明实例是什么  和绘图没关系