ToolTip用法:
private ToolTip toolTip = new ToolTip();
int x, y;
/// <summary>
/// 鼠标放在任意任务单的型号上面时,显示该型号全称.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textGridView_MouseMove(object sender, MouseEventArgs e)
{
if (x != e.X || y != e.Y)
{
System.Windows.Forms.DataGridView.HitTestInfo info = textGridView.HitTest(e.X, e.Y);
if (info.ColumnIndex < 0 || info.RowIndex < 0)
{
toolTip.Active = false;
return;
}
else if (info.ColumnIndex != 2)
{
toolTip.Active = false;
}
else
{
DataGridViewCell cell = textGridView[info.ColumnIndex, info.RowIndex];
if (cell.Value == null)
return;
Point p = new Point(textGridView.Location.X + e.Location.X, textGridView.Location.Y + e.Location.Y);
toolTip.Active = true;
toolTip.Show(cell.Value.ToString(), this, p.X, p.Y + 50);
x = e.X;
y = e.Y;
}
}
}