Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First you have to create a method that tells the timer what to do every [put the needed number here] milliseconds.</p> <pre><code>private void randomTimer_Tick(object sender, EventArgs e) { if (conditions) { ... //stuff to do ... //more stuff to do ... //even more stuff to do } } </code></pre> <p>Then you set the timer to call this method: you can do this by using the events tab of the properties of the timer or write:</p> <pre><code>this.randomTimer1.Tick += new System.EventHandler(this.randomTimer1_Tick); </code></pre> <p>in the ProjectName.Designer.cs file in the <code>private void InitializeComponent(){}</code> method after the line <code>this.randomTimer = new System.Windows.Forms.Timer(this.components);</code>.</p> <p>And lastly you enable the timer:</p> <pre><code>private void startButton (object sender, EventArgs e) { randomTimer.Interval = timeInMilliseconds; //you can also set this in the //properties tab randomTimer.Enabled = true; } </code></pre> <p>Of course, you will have to set the button to call this method too.</p> <p>If you don't know where the Properties window is (I assume that you are using Visual C#): it's usually a tab located on the right side of the window. In order something to appear in the tab, you have to select the form you want to edit in the design view. If there is no such tab anywhere in the window of the compiler, go to "View" -> "Other Windows" and select "Properties Window".</p> <p>If the answers you have found are long and complicated, that's mostly because they are explaining the whole process with details and examples. If you use the "drag and drop" option of Visual C#, the declaration code of the forms will happen automatically, afterwards it's up to you to write the code of the methods. There are also other features that are self explanatory and make programming more pleasant. Use them!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload