text display in textbox with timer

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi,

I want to display a text "Hello" in a textbox for every 30
seconds. How can I do this?

I saw the code

Code:
static void Main()
{
Application.Run(new main());
}

private void textBox1_TextChanged(object sender,
System.EventArgs e)
{
}

Do I need to make use of the textBox1_TextChanged method?
How can I pass parameters to it?

Or, I can write my own method? But, how to display the
string line by line counted with timer? I have not deal
with timer before.

Thanks for suggestion.
 
Tom, first you need to add a timer control to your application and set the
appropriate properties (interval, etc). Once you have the timer you need to
catch the Tick event which is thrown every time your interval occurs. In
the Tick event handler you can change the value of your textbox. Here's a
sample of how to use the timer class.

http://www.csharphelp.com/archives/archive90.html
 
Here is my code:

private System.Windows.Forms.Timer timer1;

this.timer1 = new System.Windows.Forms.Timer(this.components);

this.timer1.Enabled = true;
this.timer1.Interval = 20000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

private void timer1_Tick(object sender, System.EventArgs e)
{
this.textBox1.Text = DateTime.Now + " hello .....";
}

The DateTime.Now hello does not display line by line for every 2
seconds.

How can I fix it?

Thanks for help
 
Back
Top