首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 鼠标移到dataGridView1 上 展示cell的内容

2012-06-20 
C# 鼠标移到dataGridView1 上 显示cell的内容前提: SelectionMode 设置成了 FullColumnSelect我这样写的 :

C# 鼠标移到dataGridView1 上 显示cell的内容
前提: SelectionMode 设置成了 FullColumnSelect

我这样写的 :
  public void DataGridViewSelectCells(DataGridView dgv, ToolTip toolTip)
  {
  toolTip.RemoveAll();
  string title = "";
  title = dgv.CurrentCell.Value.ToString();

  dgv.ShowCellToolTips = false;

  toolTip.ToolTipIcon = ToolTipIcon.Info;
  toolTip.ToolTipTitle = "鼠标选定信息:";
  toolTip.IsBalloon = true;//气球形状  
  toolTip.UseAnimation = true;
  toolTip.AutoPopDelay = 10000;
  toolTip.InitialDelay = 500;
  toolTip.ReshowDelay = 500;
  toolTip.RemoveAll();

  toolTip.SetToolTip(dgv, title);
  }

  private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
  {
  DataGridViewSelectCells(dataGridView1, toolTip);
  }

不行 不知道该怎么弄? 求教!!!

[解决办法]
事件方法

C# code
private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e){    if (e.RowIndex >= 0 && e.ColumnIndex >= 0)    {        var v = dataGridView1[e.ColumnIndex, e.RowIndex].Value;        DataGridViewSelectCells(dataGridView1, toolTip, v != null ? v.ToString() : null);    }} 

热点排行