FillEllipse错误

时间:2015-04-28 14:02:58

标签: c# exception graphics drawing ellipse

我收到运行此代码的 JIT编译错误

void draw(PaintEventArgs e)
{
     Graphics gr =this.CreateGraphics();
     Pen pen = new Pen(Color.Black, 5);
     int x = 50;
     int y = 50;
     int width = 100;
     int height = 100;
     gr.DrawEllipse(pen, x, y, width, height);
     gr.Dispose();
     SolidBrush brush = new SolidBrush(Color.White);
     gr.FillEllipse(brush, x,y,width,height);
 }

错误说: 系统参数异常:无效参数 FillEllipse(Brush,int32 x,int32 y,int32 width,int 32 height);

1 个答案:

答案 0 :(得分:0)

由于您传递的是PaintEventArgs e,您可以并且应该使用其e.Graphics

既然你没有创造它,就不要处理它!

但是你创建的那些PensBrushes应该被处理掉或者更好,在using条款中创建它们!对于SolidBrush,我们可以使用标准Brush,我们无法更改标准void draw(PaintEventArgs e) { Graphics gr = e.Graphics; int x = 50; int y = 50; int width = 100; int height = 100; gr.FillEllipse(Brushes.White, x, y, width, height); using (Pen pen = new Pen(Color.Black, 5) ) gr.DrawEllipse(pen, x, y, width, height); } ,也不得弃置!

为了确保Fill不会覆盖Draw,我已经切换了订单。

所以,试试这个:

DECLARE
   CURSOR cursor_ab IS
      SELECT num_ab FROM abonne;
BEGIN
   OPEN cursor_ab;

   LOOP
      FETCH cursor_ab INTO numeroab;

      EXIT WHEN cursor_ab%NOTFOUND;
      DBMS_OUTPUT.put_line (numeroab);
   END LOOP;

   CLOSE cursor_ab;
END;
/