我正在创建一个带有自定义边框的表单。我想使用 onPaint 覆盖绘制自己的边框。不幸的是,当我只使用下面的代码时,我得到了图像的痕迹。
有谁知道如何解决这一问题?是的,我已将 DoubleBuffered 设置为 true。
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
// Background
g.FillRectangle(new SolidBrush(ColorTranslator.FromHtml("#EFEFF7")), new Rectangle(0, 0, this.Width - 1, this.Height - 1));
// Outer Borders
g.DrawImage(Resources.Resource.OuterBorderTopLeft, new Rectangle(0, 0, 13, 13));
g.DrawImage(Resources.Resource.OuterBorderTopLeft1, new Rectangle(13, 0, 221, 13));
g.DrawImage(Resources.Resource.OuterBorderTopLeft2, new Rectangle(0, 13, 13, 221));
g.DrawImage(Resources.Resource.OuterBorderTopRight, new Rectangle(this.Size.Width - 13, 0, 13, 13));
g.DrawImage(Resources.Resource.OuterBorderTopRight1, new Rectangle(this.Size.Width - 13, 13, 13, 221));
g.DrawImage(Resources.Resource.OuterBorderTopRight2, new Rectangle(this.Size.Width - 234, 0, 221, 13));
g.DrawImage(Resources.Resource.OuterBorderBottomLeft, new Rectangle(0, this.Size.Height - 13, 13, 13));
g.DrawImage(Resources.Resource.OuterBorderBottomLeft1, new Rectangle(0, this.Size.Height - 234, 13, 221));
g.DrawImage(Resources.Resource.OuterBorderBottomLeft2, new Rectangle(13, this.Size.Height - 13, 221, 13));
g.DrawImage(Resources.Resource.OuterBorderBottomRight, new Rectangle(this.Size.Width - 13, this.Size.Height - 13, 13, 13));
g.DrawImage(Resources.Resource.OuterBorderBottomRight1, new Rectangle(this.Size.Width - 234, this.Size.Height - 13, 221, 13));
g.DrawImage(Resources.Resource.OuterBorderBottomRight2, new Rectangle(this.Size.Width - 13, this.Size.Height - 234, 13, 221));
base.OnPaint(e);
}