Luigi

Luigi

  • NA
  • 7
  • 0

my own paintevent

Jul 21 2005 4:48 AM
my program (GUI) has static drawing using GDI+, the form calls the OnPaint method to do this, what i am struggling to do is to have a (and more than 1) method that calls another paint event (moving a rectangle etc) seperate to the OnPaint method, so when a user clicks a button "MyPaintEventHandler" is fired, i just cant fathom out how to attach the event handler to the button click and then call MyPaintEventHandler, so far I have created a link by

Code:
this.button1.Click += new EventHandler(button1.Click);
this.Paint += new PaintEventHandler(this.MyPaintEventHandler);

private void button1_Click(object sender, EventArgs e)
{
this.Invalidate();
}

private void MyPaintEventHandler(object sender, PaintEventArgs e)
{
//drawing code goes here
}

but this doesnt work, MyPaintEventHandler never gets called, the OnPaint method does on every button click does.

please help, i been trying various ways with no success so far

thanks

luigi

Answers (1)