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

 

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

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

来达到此效果。spa

 

 

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

复制代码
复制代码
 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         }
复制代码
复制代码
相关文章
相关标签/搜索