I have a DataGridView that shows student's points for each lesson and at some point I should show some information about the point via Tooltip. What I want is when user enters a specific cell, after 2 seconds ToolTip will appear at current cell, will be shown 2 seconds time and shows information about the point. I used that code:
private void dgwPNotlar_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
var hucre = dgwPNotlar.CurrentCell;
var hucre_loc = dgwPNotlar.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false);
toolTip1.Show("//Info&" + e.ColumnIndex.ToString() + "&" + e.RowIndex.ToString(), dgwPNotlar, hucre_loc.X, hucre_loc.Y);
}
I set AutomaticDelay 500, AutoPopDelay 2000, InitialDelay 2000 and Reshow Delay 2000 for ToolTip. But ToolTip comes immediately when I enter a Datagridview cell and does not vanish. When I check my code, I saw this method was called several times although mouse stays still in the cell.
What can I do?
All of that "Auto" stuff is irrelevant if the ToolTip
is not being displayed automatically. You're showing it manually so there's no delay. If you want a delay then you need to use a Timer
.
If you want a delay of 2 seconds then Start
a Timer
with an Interval
of 2000 and Show
to ToolTip
in the Tick
event handler. You can handle the CellMouseLeave
event of the grid too and Stop
the Timer
there, thus cancelling the tip before it's shown if the user leaves that cell before the delay's up.