gpt4 book ai didi

.net - 表单背景颜色设置为淡色

转载 作者:行者123 更新时间:2023-12-01 10:07:55 26 4
gpt4 key购买 nike

如何设置附件中指定的表单的背景颜色?

enter image description here

最佳答案

一种方法是直接使用图像作为表单的 BackgroundImage

如果你想通过程序实现这一点(更灵活),你可以使用 OnPaintBackground 手动绘制窗体的背景:

protected override void OnPaintBackground(PaintEventArgs e)
{
using (var brush = new LinearGradientBrush
(DisplayRectangle, Color.Black, Color.DarkGray, LinearGradientMode.Vertical))
{
e.Graphics.FillRectangle(brush, DisplayRectangle);
}
}

protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Invalidate(); // Force repainting on resize
}

结果:

Gradient

关于.net - 表单背景颜色设置为淡色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8664973/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com