我如何绘制 X?

How do I draw an X?

所以我试着画了一个X:

e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.DrawLine(new Pen(Color.Black, 1), 
                     this.Width + 20 - 50,  
                     20,  
                     this.Width + 25 - 50, 
                     10);

e.Graphics.DrawLine(new Pen(Color.Black, 1),  
                     this.Width - 20 + 50,  
                     20,  
                     this.Width + 25 - 50, 
                     10);

但它看起来像一把斧头。无论我为第二行代码设置哪个值,它都是不正确的。

DrawLine(pen, startPoint_X, startPoint_Y, stopPoint_X, stopPoint_Y);

你的两条线都是相同的停止点坐标,所以它会画一个 V。 第二件事是第二行的 X 坐标大于控件的宽度,因此第二行的起点将超出您的控制范围

10 x 10 X 只需添加位置 self

e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.DrawLine(new Pen(Color.Black, 1), 
                     1,  
                     1,  
                     10, 
                     10);

e.Graphics.DrawLine(new Pen(Color.Black, 1),  
                     1,  
                     10,  
                     10, 
                     1);