Click here to Skip to main content
15,935,728 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,

I have one application which is called as auto click event by the help of C# windows application.

My doubts are:

I have a button and when I click it, it is showing a message box like "hi" which is mentioned by the below code.

What I want to do is I need to click one time on the button of my form and then message box will display which is mentioned by the above point and this message box will I need to come frequently without I click button?

Please let me know if any one knows about this solution.

my code is:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            route();
        }

        public void  route()
        {
            MessageBox.Show("hi");
        }
    }
}


Thank you in advance..
Posted
Updated 14-May-13 4:11am
v3
Comments
[no name] 14-May-13 10:11am    
So start a timer on your button click that shows your messagebox.
Johnny J. 14-May-13 10:12am    
Why don't you submit your answer as a solution? This IS a solution, not just a comment! This way, the question can not be marked as resolved.
[no name] 14-May-13 10:22am    
Yes you are correct. I will see if I can stretch this out to make it more like an answer.

1 solution

I think what you are asking is to show a message box multiple times without clicking a button for each showing. A possible solution would be to use a timer that is started when you click the button then when the timer elapses, show the message box.
See http://msdn.microsoft.com/en-us/library/system.timers.timer%28v=vs.71%29.aspx[^]

I would caution you though, I do not think that this is really a good idea (showing message boxes automatically) as it tends to anger users when they have to dismiss message boxes continually.
 
Share this answer
 
Comments
Johnny J. 14-May-13 10:29am    
Threw together a quick code sample just for the hell of it:

public partial class Form1 : Form
{
Timer tmr = new Timer();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
tmr.Tick += new System.EventHandler(tmr_Tick);
tmr.Interval = 1000;
tmr.Enabled = true;
}

private void tmr_Tick(object sender, EventArgs e)
{
tmr.Enabled = false;

route();

tmr.Enabled = true;
}
}

:-)
[no name] 14-May-13 10:48am    
Thanks

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