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

来达到此效果。

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

  private void dgvProduct_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex != - && e.RowIndex != -)
{
if (ds1 != null && dgvProduct.CurrentRow.IsNewRow == false && dgvProduct.CurrentRow.Cells[].Value.ToString() != "")
{
if (dgvProduct[dgvProduct.CurrentCell.ColumnIndex, dgvProduct.CurrentCell.RowIndex].Value.ToString() != "")
{
dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText = "当前行基本信息:" + "\n";
dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += " 全球唯一码:" + dgvProduct[, dgvProduct.CurrentCell.RowIndex].Value + "\n";
dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += " 料号:" + dgvProduct[, dgvProduct.CurrentCell.RowIndex].Value + "\n";
dgvProduct[e.ColumnIndex, e.RowIndex].ToolTipText += " 名称:" + dgvProduct[, dgvProduct.CurrentCell.RowIndex].Value + "\n"; }
} }
}

C# 鼠标悬停在datagridview的某单元格,显示悬浮框效果的更多相关文章

  1. 设置DataGridView的某个单元格为ComboBox

    怎么将DataGridView的 某个单元格设为ComboBox的样式而不是整列都改变样式? 1.最简单的方法:利用DataGridView提供的DataGridViewComboBoxCell. 写 ...

  2. DataGridView单元格显示GIF图片

    本文转载:http://home.cnblogs.com/group/topic/40730.html DataGridView单元格显示GIF图片 gifanimationindatagrid.ra ...

  3. EasyUI datagrid单元格文本超出显示省略号,鼠标移动到单元格显示文本

    nowrap : true;  是前提 $('#×××').datagrid({ nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取 }); 省略号样式: <sty ...

  4. DataGridView单元格显示密码

    DataGridView单元格显示密码 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormatt ...

  5. 工作总结 1 sql写法 insert into select from 2 vs中 obj文件和bin文件 3 npoi 模板copy CopySheet 最好先全部Copy完后 再根据生成sheet写数据 4 sheet.CopyRow(rowsindex, rowsindex + x); 5 npoi 复制模板如果出现单元格显示问题

    我们可以从一个表中复制所有的列插入到另一个已存在的表中: INSERT INTO table2SELECT * FROM table1; 或者我们可以只复制希望的列插入到另一个已存在的表中: INSE ...

  6. WinForm中DataGridView复制选中单元格内容解决方案

    WinForm中DataGridView鼠标选中单元格内容复制方案 1.CTR+C快捷键复制 前提:该控件ClipboardCopyMode属性设置值非Disable: 2.鼠标框选,自定义代码实现复 ...

  7. Windows Forms DataGridView中合并单元格

    Windows Forms DataGridView 没有提供合并单元格的功能,要实现合并单元格的功能就要在CellPainting事件中使用Graphics.DrawLine和 Graphics.D ...

  8. DataGridView 获取当前单元格

    获取DataGridview控件中的当前单元格,是通过DataGridview的Rows属性和Column属性的索引来取得的,他们的索引都是从0开始的. Private void datagridvi ...

  9. C# DataGridView中合并单元格

    /// 合并GridView列中相同的行 /// /// GridView对象 /// 需要合并的列 public static void GroupRows(GridView GridView1, ...

随机推荐

  1. Run Configuration error:broken configuration due to unavailable

    希望大家一起来,毕竟大家都不会使用这个Androidstudio,一起扩展这方面的知识量 http://forums.opengamma.com/t/intellij-code-compiles-bu ...

  2. [Java] 字符流 Writer,输出字符数据PrintWriter

    package test.stream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Fi ...

  3. [ActionScript 3.0] AS3 时间日期格式化DateTimeFormatter类的运用

    import flash.globalization.DateTimeFormatter; var _timeFormatter:DateTimeFormatter; var _dateFormatt ...

  4. webstrom插件:如何设置才能让webstrom能提示bootstrap的语法

    <link href="bootstrap.min.css" rel="stylesheet"> <link href="boots ...

  5. 编译 proto 文件到指定语言的代码

    由于 Protocol Buffers 3 的正式版还没有发布,在官网(https://developers.google.com/protocol-buffers/docs/downloads)目前 ...

  6. flash 读取系统默认编码

    java有类可以直接读取,但貌似flash没有. Charset.defaultCharset(); 但是浏览器里可以有. document.defaultCharset;//从当前的区域语言中获取默 ...

  7. python连接hiveserver2

    sudo pip install pyhs2 网上找的例子: #!/usr/bin/env python # -*- coding: utf-8 -*- # hive util with hive s ...

  8. (转)C#精确时间计时器

    原文地址:http://blog.sina.com.cn/s/blog_699d3f1b01012vgb.html 1 调用WIN API中的GetTickCount [DllImport(" ...

  9. windows下如何使用makefile编译

    1. 编写makefile. 2. 使用nmake进行编译, vs2010或者其他都是用nmake进行编译的,将bin目录添加到path环境变量中 先执行vcvars32.bat 再执行nmake

  10. 如何在 Git 里撤销(几乎)任何操作

    任何版本控制系统的一个最有的用特性就是“撤销 (undo)”你的错误操作的能力.在 Git 里,“撤销” 蕴含了不少略有差别的功能. 当你进行一次新的提交的时候,Git 会保存你代码库在那个特定时间点 ...