【问题标题】:Is this possible to change or set the Padding Color of a Windows Form?这是否可以更改或设置 Windows 窗体的填充颜色?
【发布时间】:2014-01-21 05:35:47
【问题描述】:

我想改变我的 windows 窗体padding 颜色,我该怎么做才能帮到我....

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

【问题讨论】:

  • 覆盖 OnPaintBackground() 并以您喜欢的方式绘制它。
  • @Hans Passant - 我该怎么做,你会解释更多..

标签: c# .net winforms linq


【解决方案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);
}

设置完填充后,您就暴露了底层表单的背景。因此,只需使用您想要显示的颜色来绘制它。

【讨论】:

    猜你喜欢
    • 2021-12-07
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-16
    相关资源
    最近更新 更多