我用过
Pen pen = new Pen(Color.Red);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
塑造矩形的边框,但现在我只需要显示该矩形的角。
最佳答案
可以通过Paint
事件处理函数中的DrawLine
函数自行绘制,如下所示:
Pen pen = new Pen(Color.Red);
private void Form1_Load(object sender, System.EventArgs e)
{
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
}
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawLine(pen, 0, 0, pictureBox1.Right, 0);
g.DrawLine(pen, 0, 0, 0, pictureBox1.Bottom);
}
这是一个用例,也许您需要其他坐标,但您可以轻松修复它。
关于c# - 只绘制矩形的角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20626766/