How do I change the max value of the progress bar to the number that the user input in the textbox? c# -


how set maximum value of progress bar value input user in textbox on windows application form? here current code. need max value value input. need print current time , date.

private void btnprognum_click(object sender, eventargs e) {                          progbarnum.maximum = 10;     backgroundworker1.workerreportsprogress = true;     backgroundworker1.runworkerasync(); }  private void backgroundworker1_dowork(object sender, doworkeventargs e) {     int = 1;     int endprog = convert.toint32(txtnumprog.text);     while (i <= endprog )     {         system.threading.thread.sleep(500);         backgroundworker1.reportprogress(i);         i++;     } }  private void backgroundworker1_progresschanged_1(object sender, progresschangedeventargs e) {     progbarnum.value = e.progresspercentage;         lbloutprog.text = datetime.now.tostring();     } } 

        private void btnprognum_click(object sender, eventargs e)         {         int n = int.parse(txtnumprog.text);         int counter = 0;         while (counter != n + 1)         {             counter++;         }             progbarnum.maximum = n;             backgroundworker1.runworkerasync();             backgroundworker1.workerreportsprogress = true;         }      private void backgroundworker1_dowork(object sender, doworkeventargs e)     {         int = 1;         int n = int.parse(txtnumprog.text);         while (i <= n )         {             system.threading.thread.sleep(500);             backgroundworker1.reportprogress(i);             i++;          }     }       private void backgroundworker1_progresschanged_1(object sender, progresschangedeventargs e)     {     progbarnum.value = e.progresspercentage;         lbloutprog.text = datetime.now.tostring();     } 

here update of me fixing problem had passing new max value progress bar. dont think need second while-loop it. works way, seems ment require 1 while loop.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -