可以自定义短划线,如
float[] f = { 15, 5, 10, 5 };
p.DashPattern = f;
f = { 15, 5, 10, 5 };表示短划线时这4个元素的循环15像素的短线,接着是5像素的空隙,接着又是10像素的短线和5像素的空隙
例如:
1 private void Form1_Paint(object sender, PaintEventArgs e)
2 {
3 Graphics g = e.Graphics;
4 g.FillRectangle(Brushes.White, this.ClientRectangle);
5 Pen p = new Pen(Color.Black, 1);
6 float[] f = { 15, 5, 10, 5 };
7 p.DashPattern = f;
8 g.DrawRectangle(p, 10, 10, 80, 200);
9 p.Dispose();
10 }
其他的一些画笔设置示例
p.DashStyle =DashStyle.Solid;
p.DashStyle =DashStyle.Dash;
p.DashStyle =DashStyle.DashDot;
p.DashStyle =DashStyle.DashDotDot;
p.DashStyle =DashStyle.Dot;