日期:2014-05-18  浏览次数:20778 次

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);
    }
}