2014-01-21 51 views
1

我想改变填充颜色我窗口形式我该怎么办这个帮我的....可以更改或设置Windows窗体的填充颜色吗?

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

覆盖OnPaintBackground()并以任何你喜欢的方式绘制它。 –

+0

@Hans Passant - 我怎么能这样做,你会解释更多.. – Coderz

回答

1

在你的表单代码:

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); 
} 

将其具有的填充,你已经暴露了底层窗体的背景。所以只需用你想要展示的颜色来画。

+0

谢谢它会真的有帮助.... :-) – Coderz

+1

这不工作,如果窗体是MDI容器...寻找解决方案.. 。 –

相关问题