Question

As shown in the screenshot, my ProgressBar1.Value updates properly, but not my TaskbarItemInfo.ProgressValue:

enter image description here

This is the code I am using to update both:

void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    // Set the Value porperty when progress changed.
    this.ProgressBar1.Value = (double)e.ProgressPercentage;

    this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
    this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100;
}

How can I make my TaskbarItemInfo update properly?

Était-ce utile?

La solution

this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100;

It looks to me that you are dividing an int with another int therefore the result will be an int when a double is expected.

Simply try to suffix 100 with a "d" (making it a double) :

this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100d;

Autres conseils

I would do the following:

TaskbarItemInfo.ProgressValue = ProgressBar1.Value /(double)ProgressBar1.Maximum;

This ensures that the taskbar progress mirrors the progressbar's, even if Maximum is set to something other than 100.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top