473,233 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

System.Timers.Timer question ???

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
Dec 12 '05 #1
1 2080
Have you any idea how many "mousemove" events are fired when you move your
mouse over an interface object? Quite a few. It just depends on how long you
move your mouse over the object. If you only want to handle the event once,
you need to use some sort of boolean variable that is checked before
execting the MessageBox code. The handler would check the value, see if it
is false, and if not, set it to false, and execute code. If you want it to
fire more than once, you also need to have a way of turning it back on. How
you do this is up to you.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"melanieab" <me*******@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
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

Dec 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
9
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I...
10
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
2
by: cntams | last post by:
All, I have a Windows Service and it has one System.Timers.Timer that fires every 500 milliseconds. Now I have noticed that there's a bug in System.Timers.Timer when it's being used combined with...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
2
by: BobAtVandy | last post by:
I'll greatly appreciate any help on this. Actually 2 questions: 1. I believe I need to use the Windows timer System.Timers.Timer . The examples I find on the web all access that timer by...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.