WinForm中的DataGridView单击单元格时,在内容周围总有一条虚线线怎么去掉。

m2008huan 2008-12-08 05:06:54
在winform里的datagridview里,单元格鼠标单击时总会有一条虚线,是虚线哦。我怎么也去不掉,在网上也没有搜到,难道是太简单了。
...全文
545 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
luluyy 2010-07-22
  • 打赏
  • 举报
回复
顶起来
fan7421436 2010-05-01
  • 打赏
  • 举报
回复
好贴 顶起来
捷哥1999 2010-05-01
  • 打赏
  • 举报
回复
好贴,顶起来!
vbmscomm 2010-05-01
  • 打赏
  • 举报
回复
这个还没有做过啊
astro 2010-05-01
  • 打赏
  • 举报
回复
经典!
xu_2007 2008-12-08
  • 打赏
  • 举报
回复
好贴
net5i 2008-12-08
  • 打赏
  • 举报
回复
刚给搂主写了个代码,搂主可以参考:
private void dataGridView1_Paint(object sender, PaintEventArgs e)
{
DataGridViewCell cell = this.dataGridView1.CurrentCell;
if (!this.dataGridView1.ContainsFocus || cell == null)
return;
Rectangle bounds = this.GetCellBounds(cell);
bounds.X += 1;
bounds.Y += 1;
bounds.Width -= 2;
bounds.Height -= 2;
using (Pen pen = new Pen(SystemColors.Highlight))
{
e.Graphics.DrawRectangle(pen, bounds);
}
}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
this.dataGridView1.Invalidate();
}


上面使用了一个函数:GetCellBounds
这个函数搂主可以从下面贴中,我在13楼写的代码:

http://topic.csdn.net/u/20081129/11/4eb00964-d24c-4332-8164-9823c89e47b6.html
net5i 2008-12-08
  • 打赏
  • 举报
回复
简单的做法就是:
搂主重绘一个背景颜色的框来覆盖这个焦点框
m2008huan 2008-12-08
  • 打赏
  • 举报
回复
这一条虚线 朋友们都知道是吧
怎么处理呢,老板看起来不好看,非得让处理,不行啊。高手呢?帮帮忙!!!
ljhcy99 2008-12-08
  • 打赏
  • 举报
回复
看看cellborderstyle 属性
长沙三毛 2008-12-08
  • 打赏
  • 举报
回复
Focus的虚框,不太好处理

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧