The timer in this c# program does not function -


when type in letter current time have declared @ top , not work because after amount of time declared letter isn't locked in.

for example go p q after 5 secs when want go p(then save letter in textbox) p again allowing me make words

here code:

namespace minikeyboardassignment {     public partial class form1 : form     {         //how long i've set interval go for, means how long timer on before current letter saved//         int timerinterval = 2000;           bool button_but1 = true;         int button1_clicked = -1;         bool button_but2 = true;         int button2_clicked = -1;         bool button_but3 = true;         int button3_clicked = -1;         bool button_but4 = true;         int button4_clicked = -1;         bool button_but5 = true;         int button5_clicked = -1;         bool button_but6 = true;         int button6_clicked = -1;         bool button_but7 = true;         int button7_clicked = -1;         bool button_but8 = true;         int button8_clicked = -1;         bool button_but9 = true;         int button9_clicked = -1;         bool button_but10 = true;         int button10_clicked = -1;         bool button_but12 = true;         int button12_clicked = -1;          public form1()         {             initializecomponent();         }          private void form1_load(object sender, eventargs e)         {             mode_textbox.text = "multipress";         }           private void timer1_tick(object sender, eventargs e)         {             counter = convert.toint16(textbox1.text);             counter++;             textbox1.text = convert.tostring(counter);             timer1.enabled = true;       }          private void button1_click(object sender, eventargs e)         {             string sequence1 = "1";             if (button_but1 == true)             {                 button1_clicked++;                 textbox.text = convert.tostring(listbox1.items[button1_clicked]);                 listbox11.items.add(sequence1);                 counter++;                 textbox1.text = convert.tostring(counter);                 button_but1 = false;                 timer1.enabled = true;             }             else             {                 button1_clicked++;             }             characterstring[convert.toint16(textbox1.text)] = convert.tostring(listbox1.items[button1_clicked]);             textbox.text = characterstring[0] + characterstring[1] + characterstring [2] + characterstring [3] + characterstring [4] + characterstring [5] + characterstring [6] + characterstring [7] + characterstring [8] + characterstring [9] + characterstring [10] + characterstring [11] + characterstring [12] + characterstring [13] + characterstring [14] + characterstring [15] + characterstring [16] + characterstring [17] + characterstring [18] + characterstring [19] + characterstring [20];         } 

make sure have initialized textbox , timer:

public form1()     {         initializecomponent();         this.textbox1.text = "1";         this.timer1.interval = timerinterval;         this.timer1.start();     } 

also, don't need set timer1.enabled in timer1_tick method. setting enabled true same calling start (which, in example, done in constructor.) alternatively, can continue enable timer when button1 clicked.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -