Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If I run the application after 2 minutes my textbox1 and label1 become invisible. If I move the mouse pointer again textbox1 and label become visible. Now what I need is after 2 minutes again the textbox1 and label1 need to invisible and if I move the mouse pointer it should visible again.
This process should repeat continuously until I close the application.
Posted
Updated 20-Oct-12 5:34am
v3
Comments
Rajesh Kariyavula 19-Oct-12 23:54pm    
Have you tried anything so far?
selva_1990 20-Oct-12 2:05am    
ya after 2 min it'll hide and if i move cursor it become visible again.... upto tat i finished... wat i need is tat process should continues until i close the app....
Silent Guardian 20-Oct-12 0:25am    
so you want ur textbox and label to be invisible after every 2min and when you move ur mouse over it ,it should become visible?
selva_1990 20-Oct-12 2:13am    
every 2 min it should hide and if i move the cursor over the form it need to visible again,from tat point after 2 min it need to hide...again if move the cursor it need to visible again...
Sandeep Mewara 20-Oct-12 1:28am    
and the issue is? What have you tried so far? Where are you stuck?

1 solution

Its very clear for us to identify your problem after you post your code.
C#
public Form1()
{
    InitializeComponent(); 
    // Set the timer interval here
    timer1 = new Timer();
    timer1.Interval = 2000; // means 2 seconds
    // timer1.Interval = 2 * 60 * 1000 // means 2 minutes
    timer1.Tick += timer1_Tick;
}

C#
private void timer1_Tick(object sender, EventArgs e)
{
    textbox1.Visible = false;
    label1.Visible = false;
    timer1.Stop();
}

C#
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
    label1.Visible = true;
    textBox1.Visible = true;
    // Restart Timer
    timer1.Stop();
    timer1.Start();
}

Added (edit)
C#
private void Form1_Load(object sender, EventArgs e)
{
    // Automatic start timer at Form Load
    timer1.Start();
}
 
Share this answer
 
v4
Comments
Thomas Daniels 20-Oct-12 10:39am    
But you didn't set the Tick event handler!
You forgot timer1.Tick += timer1_Tick
adriancs 20-Oct-12 10:44am    
I follow the OP's code. The OP can run the code with timer start. There is a very high possibility that the Timer Tick event handler is set in the Form1.Designer.cs (UI design) by the OP.
adriancs 20-Oct-12 10:48am    
However, I do miss out the timer.Start() at Page Load.
adriancs 20-Oct-12 22:32pm    
I think you are right. He said the timer is not running. Perhaps timer1.Tick += timer1_Tick is not set. But how come he can run it in the 1st place? nevermind, just add it anyway.
selva_1990 20-Oct-12 12:21pm    
timer is not running..... program simply running without error no change

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900