Makinde A. Israel

Makinde A. Israel

  • NA
  • 166
  • 19.4k

Multi-Page Winform and Custom UserControl

Dec 12 2016 5:41 AM
Good day. please am having a challenge concerning a custom usercontrol. I have a custom usercontrol "countdownTimer" which uses System.Windows.Forms.Timer to countdown and update the interface. I have say 4 different Forms say form1, form2, form3 and form4. There is a panel and a button on form1 which when clicked will instantiate form2 and sets it's TopLevel property to false, then add it to the panel on form1. The form2 has a button(check). I use this form2 to get user information which it will check up in a database when the button 'check' is clicked. if the information exists or is correct then it instantiate the form3 and add it to the panel on form1 after setting the form3's TopLevel property to false. on form3 I have the custom usercontrol "countdowntimer" while the given time has not elapsed form4 will be opened and the countdowntimer will be started by calling it's Start() method, but if time elapsed it will close form4. Also on form4 there is a button "resettimer" which should reset the countdowntimer on form3 when pressed. The problem is that, on form3 when the countdowntimer.Start() method is called, the countdowntimer will not update but the System.Windows.Forms.Timer inside the usercontrol will start. Again when the "reset" button on form4 is clicked it sets the countdowntimer's public property Duration to say 30min the countdowntimer should refresh and restart but it will not. I opened another window form project and add the custom usercontrol to it all everything was working fine. it was updating every seconds the public property Duration and the method Start() was working fine. please help me, what could be the problem?