【问题标题】:How to get the percentage from ProgressBar and pass it to the "label.text"?如何从 ProgressBar 获取百分比并将其传递给“label.text”?
【发布时间】:2021-08-09 08:19:10
【问题描述】:

在程序中,进度条的百分比未显示。

但是,当我跟踪它时,“label.text”具有值。

谢谢!

【问题讨论】:

标签: c# progress-bar


【解决方案1】:

你应该使用异步编程,我用按钮、进度和标签写了一个简单的例子来模拟进度更新。 当点击按钮时,进度开始更新。

 private async void button1_Click(object sender, EventArgs e) {
     var c = 0;
     // 100 is progress max value for example
     while (c < 100) {
        await Task.Delay(500);
        this.progressBar1.Value = c++;
        // Set label!
     }
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-22
    • 1970-01-01
    • 2019-03-06
    • 2023-03-22
    • 1970-01-01
    • 2018-11-05
    • 2013-02-22
    • 2017-02-12
    相关资源
    最近更新 更多