fork download
  1. public partial class Form1 : Form
  2. {
  3. private Point _defaultLocation;
  4.  
  5. public Form1()
  6. {
  7. InitializeComponent();
  8.  
  9. this._defaultLocation = this.textBox1.Location;
  10. }
  11.  
  12. private void button1_Click(object sender, EventArgs e)
  13. {
  14. if (this.timer1.Enabled)
  15. this.timer1.Enabled = false;
  16.  
  17. this._moveDistance = 1;
  18. this.textBox1.Location = this._defaultLocation;
  19. this.textBox1.Update();
  20. this.timer1.Enabled = true;
  21. }
  22.  
  23. private int _moveDistance = 1;
  24.  
  25. private void timer1_Tick(object sender, EventArgs e)
  26. {
  27. this.textBox1.Location = new Point(this.textBox1.Location.X + this._moveDistance, this.textBox1.Location.Y);
  28. this.textBox1.Update();
  29.  
  30. this._moveDistance = this._moveDistance * 2;
  31.  
  32. if (this.textBox1.Location.X > this.Width)
  33. this.timer1.Enabled = false;
  34. }
  35. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty