Home > DeveloperSection > Forums > How to call Form_Paint event on button click event?
Tanuj Kumar

Total Post:134

Posted on    July-16-2012 4:23 AM

 C# C# 

 1 Reply(s)
 3784  View(s)
Rate this:

Hi All,

I'm facing a problem since last night actually I want to invoke Form_Paint event on button click event but I didn't getting a proper solution so far. Please resolve my problem as soon as possible.



Arun Singh

Total Post:68

Posted on    July-21-2012 1:17 AM

Hi Tanuj Kumar,
If you want to invoke Form_Paint event on button click event then you have to write code in such way:
public void draw(object sender, PaintEventArgs e)
                using (LinearGradientBrush brush = new LinearGradientBrush(ClientRectangle, Color colr1, Color colr2, LinearGradientMode.Vertical))
                    e.Graphics.FillRectangle(brush, ClientRectangle);
            catch (Exception ex)
private void btnApply_Click(object sender, EventArgs e)
            Paint += draw;

I hope it might be resolve your problem.

Don't want to miss updates? Please click the below button!

Follow MindStick