前提: 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);
}不行 不知道该怎么弄? 求教!!!
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);
}不行 不知道该怎么弄? 求教!!!
dataGridView1.Rows[0].Cells[0].ToolTipText = ...
public void DataGridViewSelectCells(DataGridView dgv, ToolTip toolTip, string value)
{
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, value);
}private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
DataGridViewSelectCells(dataGridView1, toolTip, dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString());
}
索引超出范围。必须为非负值并小于集合大小。
参数名: index
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);
}
}
//提示信息
private void dataGridView1_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
e.ToolTipText = "当前名称:" + this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
}
可以帮我看下这个帖子吗 谢谢
http://topic.csdn.net/u/20120613/18/8d5758ca-6ba2-43ab-8eef-197980c05576.html