Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Label Text does not get updated

Posted on 2013-12-14
9
Medium Priority
?
438 Views
Last Modified: 2013-12-20
I am trying to set the text of a label control based on a condition in a loop.

The condition is reached about 10 times during the loop.

The final text value is ->->->->->->->->->->->->->->

The label acts as a progress bar.

There is no error, but the label text does not get updated.

string strProgressChar = "->";
   
      for (int i = 0; i <=8000 ; i++)
       {
                intProgress++;
               
                if (intProgress == intProgressIncrement)  // increment is 300
                {
                    lblProgress.Text = lblProgress.Text + strProgressChar;  // Text is not updated
                    intProgress = 0;
                }

        }  // End  while ((line = sr.ReadLine()) != null)


Any help would be appreciated.

Thanks,
0
Comment
Question by:Dovberman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39718834
I'm not going to be much help here because I don't have access to VS for testing. When update bars do not show progress it's almost always because the processing thread you are attempting to report on is busy so it cannot also update the progress. In other words, it cannot do two things at once. You need to introduce a pause/update/resume logic at short intervals in your coding for the main process or add a second processing thread for the update (Google multi-threaded operations for asp.net) or you could do a progress bar using ajax for polling. Look here.You may need to provide the main process code to get the help you need.

That's my entire contribution to this question.
0
 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 39718872
You can't do it like this in asp.net

in ASP.Net when you're running that process the entire thing is server side, the page doesn't reload again until after all of the server side code is finished running.

If you wanted to use the label as a progress bar you would need a web service of some kind.

See below for more information:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28283009.html
0
 

Author Comment

by:Dovberman
ID: 39719177
I thought I would need a delay step.  I will try the timer and provide feedback.

Thanks,
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719294
You can try either the .Refresh method of the label control, or you could invoke whatever your language's equivalent of "DoEvents" is.  I have to use DoEvents in VB programming, but overuse can be a problem, that's why I only use it at certain intervals using the MOD function, i.e. If intRec MOD 100 = 0 Then DoEvents
0
 

Author Comment

by:Dovberman
ID: 39719559
There is no .Refresh method for a label control.
0
 
LVL 2

Expert Comment

by:DiscGolfDad
ID: 39719921
Then instead try the Refresh method of the form.
0
 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 39720314
If this is for asp.net there is no .refresh on the form.
0
 
LVL 8

Accepted Solution

by:
johny_bravo1 earned 900 total points
ID: 39723304
Well Asp.Net gives you more option for display a progress bar rather than using label.

If you are using UpdatePanel use UpdateProgress control.

Alternatively you can use javascript/ jquery, check below links for javascript

http://www.javascriptkit.com/script/script2/progressbar.shtml

http://jqueryui.com/progressbar/#default
0
 

Author Closing Comment

by:Dovberman
ID: 39731224
Thank you
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question