[英]How to draw rectangle with solid border?
I use an answer from How do i make a picturebox selectable? 我使用“ 如何选择图片框”中的答案? to make PictureBox selectable. 使PictureBox可选。
All works, but lines of border rectangle are dashed. 所有的作品,但边框矩形的线是虚线。 How can I make it solid? 我如何使其牢固?
It it because 是因为
ControlPaint.DrawFocusRectangle(pe.Graphics, rc);
is drawing a dashed rectangle. 正在绘制一个虚线矩形。
To draw a solid rectangle use: 要绘制实心矩形,请使用:
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
if (this.Focused)
{
var rc = this.ClientRectangle;
rc.Inflate(-2, -2);
pe.Graphics.DrawRectangle(Pens.Black, rc);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.