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

发布时间:2020-07-10 08:31:55 作者:asianmars
来源:网络 阅读:1287

通过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);

}


推荐阅读:
  1. C#控件-显示边框的DataGridViewColumn
  2. C#窗体控件DataGridView常用设置

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

datagrid 单元格 边框

上一篇:MS17-010 "Eternal Blue(永恒之蓝)”, 修复补丁下载汇总地址!

下一篇:2、SRX笔记及基础配置

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》