Skip to content

Infragistics Community Forum / Desktop / Ultimate UI for Windows Forms / Increment ProgressBarInfo in UltraStatusBar

Increment ProgressBarInfo in UltraStatusBar

New Discussion
Baba Goud Gadiga
Baba Goud Gadiga asked on Oct 2, 2018 7:57 PM

Hello team,

I have a UltraStatusBar and added a Panel whose style is set to Progress. I want to show the user the progress of a long running process with its value. I set the Minimum as 0 and Maximum values as 100.

Now my I have a loop which runs for 265 iterations. Under this loop i am trying to update the ProgressBarInfo value as below, does not seem  mathematically correct though 🙂

ultraStatusBar1.Panels[“TestProgress”].ProgressBarInfo.Value =1;

for(int i=0;i<265;i++)

{

if( ultraStatusBar1.Panels[“TestProgress”].ProgressBarInfo.Value < 100 &&
(ultraStatusBar1.Panels[“TestProgress”].ProgressBarInfo.Value + 100 / 265 < 100))
{
ultraStatusBar1.Panels[“TestProgress”].ProgressBarInfo.Value += 100 / 265;
}

}

I guess the ProgressBarInfo.Value will only increment by 1 and since my loop has to run for 265 times  100/265 gives me a value of 0.377, the value is not getting incremented by this decimal value.

Could you suggest me a logic so that I can show the Progress to the user with 265 iterations when ProgresBarInfo Minimum as 0 and Maximum values as 100?

 

Any suggestions are highly appreciated.

Sign In to post a reply

Replies

  • 0
    Divya Jain
    Divya Jain answered on Sep 28, 2018 7:26 PM

    Hello,

    Thank you for posting. Try to set its maximum values to 265 and so that instead of getting a decimal value you will get integer and value keep incrementing.

    Please let me know if it helps or needs further assistance.

    • 0
      Baba Goud Gadiga
      Baba Goud Gadiga answered on Sep 28, 2018 7:31 PM

      Thank you Divya.

      Setting the maximum value to 265 will surely increment the ProgressBarInfo value, but I do not want the user to see that the loop runs for 265 times. The value should be displayed between 1-100  when though the loop runs for 265 times. Its like process running and the user wants to see how much % of processing is left.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Oct 1, 2018 7:59 PM

        I’m not sure I understand the distinction you are making here.

        It’s generally not a good idea to update the ProgressBar by adding to it’s current value. This makes things complicated, because you can run into rounding errors. It’s better practice, in my experience to explicitly set the Value to something that indicates how far along your process has progressed.

        If your process has X steps, then the simplest thing to do is to set the Minimum to 0 and the Maximum to X, and then set the Value of the progress bar to how many steps are completed. The ProgressBar will fill a percentage of the bar based on how much of the process is complete: (value/MaxValue). The ProgressBar figures out how much to show as filled. So what is it that you want that you are not able to achieve?

        Another approach you could potentially take (but that will give you essentially the same results) is to use 0 and 100 as you Minimum and Maximum respectively. But in that case, it would be your responsibility to do the math and convert you current step (i) and the maximum step (X) into a value from 1 to 100. Which is simple enough to do, you just use “i/X * 100”. It’s a little trickier than that, because you can’t easily divide two integers without some casting, but it’s not terribly hard.

        Beyond that, I’m not sure what you are asking.

        I have attached a sample project here that demonstrates both approaches.

         

      • 0
        Baba Goud Gadiga
        Baba Goud Gadiga answered on Oct 2, 2018 3:31 PM

        Thank you Mike.

        This is what exactly I was looking at. Maybe I could not put my question in proper words, but you got my problem [emoticon:c4563cd7d5574777a71c318021cbbcc8]

        Thank you for providing me a sample code as well, below is the code more or less I was looking for.

        for (int i = 0; i <= 265; i++)
        {
        double percentageD = ((double)i / (double)265) * 100;
        int percentage = (int)percentageD;
        progressBarPanel1.ProgressBarInfo.Value = percentage;
        this.ultraStatusBar1.Refresh();
        }

        A quick question though, when I set the ShowLabel property of the ProgressBarInfo to false, is there a way for me to  still show the progress without displaying any value/percentage of the process running? something like a UltraProgressBar control does?

      • 0
        Divya Jain
        Divya Jain answered on Oct 2, 2018 6:42 PM

        Hello , 

        Thank you for the update. 

        When you set ProgressBarInfo.ShowLabel to false it still shows the progress without showing the value and percentage of the progress so I am not sure what you are trying to achieve. 

        If you are trying to just change the label and shows the percentage of the ProgressBarInfo then you can use label property, like this:

        progressBarPanel2.ProgressBarInfo.Label = "%";

        Please let me know if you need further assistance.

      • 0
        Baba Goud Gadiga
        Baba Goud Gadiga answered on Oct 2, 2018 7:35 PM

        Thank you Divya.

        The above logic does not work for my scenario. I was able to achieve my need using a different workaround.  Added another panel to the status bar control and set its style to Control container. This panel holds the ActivityIndicator control which shows the progress of my long running process. 

      • 0
        Divya Jain
        Divya Jain answered on Oct 2, 2018 7:57 PM

        Thank you for the update.I am glad that you found the solution to your requirement.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Baba Goud Gadiga
Favorites
0
Replies
7
Created On
Oct 02, 2018
Last Post
8 years ago

Suggested Discussions

Tags

Created by

Created on

Oct 2, 2018 7:57 PM

Last activity on

Feb 19, 2026 2:49 PM