winform datagridview 重新绘制datagridview的边框。

1,根据项目的需求,要求重新绘制datagridview的边框。

如图;

 代码如下

View Code
 1  private void dgv2_Paint(object sender, PaintEventArgs e)
 2         {
 3             Color top = Color.FromArgb(160,160,160);
 4             ControlPaint.DrawBorder(e.Graphics
 5                 , dgv2.ClientRectangle,
 6                 Color.Black,
 7                 1,
 8                 ButtonBorderStyle.Solid,
 9               
10                 top,
11                 1,
12                 ButtonBorderStyle.Solid,
13          
14                 Color.Black,
15                1,
16                 ButtonBorderStyle.Solid,
17         
18                 Color.Black,
19                 1,
20                 ButtonBorderStyle.Solid
21               );
22 
23           
24         }

 这样就可以设置datagridview的边框了。

 

 

 

参考:http://hi.baidu.com/piaozuehome/blog/item/9830037e26e7a2300cd7daf0.html#0

 

 

 

posted on 2011-09-08 23:25  wtq  阅读(2667)  评论(0编辑  收藏  举报