my own paintevent

This is a discussion on my own paintevent within the C# Programming forums, part of the General Programming Boards category; my program (GUI) has static drawing using GDI+, the form calls the OnPaint method to do this, what i am ...

  1. #1
    budding software engineer luigi40's Avatar
    Join Date
    Jun 2004
    Location
    South Coast UK
    Posts
    61

    Question my own paintevent

    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

  2. #2
    budding software engineer luigi40's Avatar
    Join Date
    Jun 2004
    Location
    South Coast UK
    Posts
    61
    i did it...just created my own graphics object in the button1_Click method...easy when you know how..its just getting there :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Auto Calling Derived Fun
    By Arlenik in forum C++ Programming
    Replies: 27
    Last Post: 06-02-2008, 12:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21