Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If In a windows form application a specific button not click around two minutes, I want to display a message to click he button. Please advise.
Posted
Updated 17-Oct-12 1:28am
v2
Comments
[no name] 17-Oct-12 7:32am    
Use a timer, set the interval for two minutes, show a messasge if the button has not been clicked.
abdulsafran 17-Oct-12 9:40am    
Thanks for the reply Wes Aday, could you please provide sample coding of how to do my request?
[no name] 17-Oct-12 9:44am    
And why are you not able to write this?
abdulsafran 17-Oct-12 9:51am    
I have wrote the coding for the timer, but could you please advise me how to write "if button is not clicked" Thanks!.
[no name] 17-Oct-12 9:53am    
You are not going to do anything for that. If the button is clicked then stop or restart the timer.

Place a timer on your form with the duration you want and then throw up a message box to the user when it ticks.
 
Share this answer
 
1.create a bool value in the class to check status of button(clicked or not clicked)
C#
bool IsClicked = false;


2.set IsClicked to true if button is clicked.so add below line within button.click handling method
C#
bool IsClicked = true;

3.add following to form load event handling method.
It starts the timer and shows a messagebox if IsClicked is still not set.
C#
Timer timer = new Timer();
timer.Start();
timer.Interval = 120000;
timer.Tick += new EventHandler((o, b) => {if(!IsClicked)MessageBox.Show("Please click the button");});
 
Share this answer
 

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