0

I'm making a custom form with FormBorderStyle is none. In the form, I have a panel docked on the top of the form. The panel has some buttons docked on the right.

I overrided OnPaint for the form to draw a border for it, when I resize the form, buttons on the panel were still at their location. I tried to use form.Invalidate() but nothing happens.

I'm sorry but I'm not allowed to post picture here.

Here it the code of the form

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Rectangle borderRectangle = this.ClientRectangle;
        borderRectangle.Inflate(-1, -1);
        //ControlPaint.DrawBorder3D(e.Graphics, borderRectangle, Border3DStyle.RaisedOuter);
        ControlPaint.DrawVisualStyleBorder(e.Graphics, borderRectangle);
    }

    protected override void OnResize(EventArgs e)
    {   
        this.Invalidate(true);
    }
Johnny
  • 257
  • 2
  • 3
  • 6

1 Answers1

0

Finally, I solved the problem by removing OnResize by OnClientSizeChanged :)

protected override void OnClientSizeChanged(EventArgs e)
{
    this.Invalidate(true);
}
Johnny
  • 257
  • 2
  • 3
  • 6