G
Guest
Hi,
I'm have a datagrid, and I'm trying to have a tooltip pop up if a cell has
been hovered on for 2 seconds. I was thinking of using DataGrid.Hover, but
then decided to try this instead:
static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
private void dg_MouseMove(object sender, System.Windows.Forms.MouseEventArgs
e)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 2000;
timer.Start();
DataGrid.HitTestInfo hitInfo = dg.HitTest(e.X, e.Y);
eX = hitInfo.Column; eY = hitInfo.Row;
timer.Elapsed+=new System.Timers.ElapsedEventHandler(OnTimedEvent);
timer.AutoReset = false;
timer.Enabled = true;
}
private static void OnTimedEvent(object source,
System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("2 secs");
....add tooltip stuff here...
}
When I run it, it does wait 2 seconds before the messagebox comes up, but
then a new messagebox pops up every 1/2 second or so (even if I don't move
the mouse again). I was under the impression that timer.Autoselect would
prevent that from happening. I think I have other questions too, but I'd
like to get this step working before I do anything else.
Thanks!!!!
Mel
I'm have a datagrid, and I'm trying to have a tooltip pop up if a cell has
been hovered on for 2 seconds. I was thinking of using DataGrid.Hover, but
then decided to try this instead:
static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
private void dg_MouseMove(object sender, System.Windows.Forms.MouseEventArgs
e)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 2000;
timer.Start();
DataGrid.HitTestInfo hitInfo = dg.HitTest(e.X, e.Y);
eX = hitInfo.Column; eY = hitInfo.Row;
timer.Elapsed+=new System.Timers.ElapsedEventHandler(OnTimedEvent);
timer.AutoReset = false;
timer.Enabled = true;
}
private static void OnTimedEvent(object source,
System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("2 secs");
....add tooltip stuff here...
}
When I run it, it does wait 2 seconds before the messagebox comes up, but
then a new messagebox pops up every 1/2 second or so (even if I don't move
the mouse again). I was under the impression that timer.Autoselect would
prevent that from happening. I think I have other questions too, but I'd
like to get this step working before I do anything else.
Thanks!!!!
Mel