我试图通过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);
因此,问题是如何绘制四个边框?
慕哥9229398
相关分类