码迷,mamicode.com
首页 > Windows程序 > 详细

c# 消除datagridview 单元格选中边框

时间:2016-12-02 16:32:53      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:c#   datagrid   单元格边框   

通过CellPaint事件解决单元格选中边框问题。


public void PaintBackground (

Rectangle clipBounds,

bool cellsPaintSelectionBackground

)

参数:

clipBounds

一个指定要绘制的 DataGridView 区域的 Rectangle。


cellsPaintSelectionBackground

true 用于使用 DataGridViewCell.InheritedStyle 的 SelectionBackColor 属性的颜色绘制指定边界的背景;false 用于使用 DataGridViewCell.InheritedStyle 的 BackColor 属性的颜色绘制指定边界的背景。


public void PaintContent (

Rectangle clipBounds

)

参数

clipBounds

一个指定要绘制的 DataGridView 区域的 Rectangle。



添加DataGridView的CellPaint事件,代码如下:

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)

{

e.Handled = true;

e.PaintBackground(e.CellBounds, true);

e.PaintContent(e.CellBounds);

}


本文出自 “小森工作室” 博客,请务必保留此出处http://898779.blog.51cto.com/888779/1878835

c# 消除datagridview 单元格选中边框

标签:c#   datagrid   单元格边框   

原文地址:http://898779.blog.51cto.com/888779/1878835

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!