Coderz
Coderz

Reputation: 245

Is this possible to change or set the Padding Color of a Windows Form?

I want to change the padding color of my windows form how can i do this help me....

  this.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);

Upvotes: 2

Views: 1701

Answers (1)

DonBoitnott
DonBoitnott

Reputation: 11025

In your form code:

protected override void OnPaintBackground(PaintEventArgs e)
{
    //base.OnPaintBackground(e);  //comment this out to prevent default painting
    using (SolidBrush brush = new SolidBrush(Color.Purple))  //any color you like
        e.Graphics.FillRectangle(brush, e.ClipRectangle);
}

Having set your padding, you have exposed the underlying form's background. So just paint it with the color you want to show through.

Upvotes: 1

Related Questions