前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C# 鼠标悬停在datagridview的某单元格,显示悬浮框效果

C# 鼠标悬停在datagridview的某单元格,显示悬浮框效果

作者头像
跟着阿笨一起玩NET
发布2018-09-19 10:43:43
1.7K0
发布2018-09-19 10:43:43
举报

本文转载:http://www.cnblogs.com/bribe/archive/2013/10/08/3357345.html

今天在做项目时,看到一软件做的悬浮框效果不错,从网上搜罗了一些资料,未见到有十分好的解决办法,只能自已动手,利用datagridviewToolTipText

来达到此效果。

以下是我简单实现的代码,供参考。后续会再仔细测试,如有问题,会一并作更新:

代码语言:javascript
复制
 1  private void dgvProduct_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
 2         {
 3             if (e.ColumnIndex != -1 && e.RowIndex != -1)
 4             {
 5                 if (ds1 != null  && dgvProduct.CurrentRow.IsNewRow == false && dgvProduct.CurrentRow.Cells[0].Value.ToString() != "")
 6                     {
 7                         if (dgvProduct[dgvProduct.CurrentCell.ColumnIndex, dgvProduct.CurrentCell.RowIndex].Value.ToString() != "")
 8                         {
 9                             dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText = "当前行基本信息:"  + "\n";
10                             dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += "     全球唯一码:" + dgvProduct[0, dgvProduct.CurrentCell.RowIndex].Value + "\n";
11                             dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += "     料号:" + dgvProduct[1, dgvProduct.CurrentCell.RowIndex].Value + "\n";
12                             dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += "     名称:" + dgvProduct[2, dgvProduct.CurrentCell.RowIndex].Value + "\n";
13 
14 
15                         }
16                     }
17 
18             }
19         }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013-11-19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档