Don't work

Hello,

I'have this code but it isn't working what is here the problem:

Graphics ab;

ab = this.CreateGraphics();

ab.FillEllipse(new SolidBrush(Color.Aqua), 10, 10, 500, 500);

ab.Dispose();

Greets,

DIII




Answer this question

Don't work

  • koiravahti

    Are you calling that code in your form or control’s Load event handler (Form1_Load) If so, doing so there is pretty pointless given that the object has not been drawn yet and anything you draw to its surface will be lost when it is first displayed.

    The ideal place to call this code would be in the overridden OnPaint method of your object, that way it will draw as expected and as necessary, unlike having it in the load event handler.



  • flodis79

    Brendan Grant wrote:

    Are you calling that code in your form or control’s Load event handler (Form1_Load) If so, doing so there is pretty pointless given that the object has not been drawn yet and anything you draw to its surface will be lost when it is first displayed.

    The ideal place to call this code would be in the overridden OnPaint method of your object, that way it will draw as expected and as necessary, unlike having it in the load event handler.

    Now it works perfect, thanks

    DIII



  • Ramana G.V

    How exactly is it failing

    You need to be more specific with your problem if you want there to be any chance of anyone here being able to help you.



  • Don't work