performclick and graphics

I've written a short graphics test program. Basically the program executes when a button (button event) is pressed. I then wanted to use button.performclick in a Paint Event but the graphics in the button event does not work. I'm using a picture box as the canvas. Any suggestions. BTW the performclick does work for code other than graphics.

Answer this question

performclick and graphics

  • CGlenn

    Perhaps you need to post some code and define 'does not work', my first guess is that you're saying your code just keeps creating paint events



  • netjay

    OK here is an outline of the code..

    private void btnOK_Click(object sender,EventArgs e)

    {

      Graphics gx = DrawBox.CreateGraphics();   // DrawBox is a picturebox

      // simple graphics  here

      gx.Dispose;

    }

    // the above works fine!!!!!

     

    private void Form1_Paint(object sender, PaintEventArgs e)

    {

      btnOK.PerformClick();  // the code in the button event does not execute;

    }

    // I tried regular code in the button event and PerformClick does cause the button event code to execute.

     

     


  • performclick and graphics