我正在尝试通过 Paint 事件在我的 Winform 控件上进行一些绘画,因为为什么不这样做。我已经把它连接起来了,因为 StackOverlfow 告诉我它会起作用:
private void PaintLines(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, ClientRectangle,
Color.Gray, 1, ButtonBorderStyle.Solid,
Color.Gray, 1, ButtonBorderStyle.Solid,
Color.Gray, 1, ButtonBorderStyle.Solid,
Color.Gray, 1, ButtonBorderStyle.Solid);
}
问题是仅适用于顶部和左侧边框,而不适用于右侧或底部。这是 Designer.cs,因为我怀疑这是控件设置方式的问题。
this.lblOffset.AutoSize = true;
this.lblOffset.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblOffset.Location = new System.Drawing.Point(3, 25);
this.lblOffset.Name = "lblOffset";
this.lblOffset.Size = new System.Drawing.Size(114, 25);
this.lblOffset.TabIndex = 1;
this.lblOffset.Text = "Offset (V)";
this.lblOffset.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.lblOffset.Paint += new System.Windows.Forms.PaintEventHandler(PaintLines);
所以问题是我如何画出我的四个边框?