0

I have created custom picture buttons and now need to do some additional drawing in the main Form (that is using these buttons), so I overrode its OnPaint method.

For some reason it is never called and I do not know why.

public partial class Form1: Form
{   
 protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
John V
  • 4,855
  • 15
  • 39
  • 63
  • 1
    might be helpful http://stackoverflow.com/questions/2215393/onpaint-override-is-never-called – Sachin Feb 02 '14 at 19:21
  • Thanks, yet my problem occurs in the main Form, not inherited controls. Tried the solution, does not work. – John V Feb 02 '14 at 19:23
  • We need more information. Are you inheriting from `Form` like: `public class MainForm : Form`? – MoonKnight Feb 02 '14 at 19:32
  • Sorry - no, this is plain Form1 : Form. I added panel to which I am adding programatically picture buttons. These buttons have OnPaint overridden as well and for them it works fine. – John V Feb 02 '14 at 19:33

1 Answers1

3

I found out what was the problem - there was a GroupPanel with docking set to Fill in the Main form.

John V
  • 4,855
  • 15
  • 39
  • 63