【问题标题】:I want to show progress during the process我想在此过程中显示进度
【发布时间】:2017-12-01 07:40:57
【问题描述】:

我想在此过程中显示进度。但是程序挂起并且没有显示任何进度,直到过程结束。如何在标签中显示每个项目。 (每次对文件的操作都需要很长时间(艰苦的工作)) 我正在使用 Visual Studio 2008。VB.net 或 C# 代码

  Dim files() As String = IO.Directory.GetFiles("*.ggpf")

    For Each filename As String In files
        Label1.Text = filename


        do 
        ......
        ...... Some write operations with file goes here 

        loop 




    Next

【问题讨论】:

    标签: label progress


    【解决方案1】:

    使用进度条工具,这些是它的基本属性:

    ProgressBar1.Minimum = 0
    ProgressBar1.Maximum = FileSize
    ProgressBar1.Value = BytesSent
    

    如果您想将进度传递给对话框或标签:

    Label1.Text = String.Format("{0}%", ((ProgressBar1.Value / ProgressBar1.Maximum) * 100).ToString("F2"))
    

    【讨论】:

    • 当我有一个大循环并想用文件名更新标签时。文件名在数组中。它写入第一个项目,然后在进程结束时写入最后一个。
    • @GGSoft 所以你想随着进度从头到尾显示文件名?给我看看你的代码。
    猜你喜欢
    • 1970-01-01
    • 2017-01-02
    • 2022-01-11
    • 1970-01-01
    • 2012-12-09
    • 2020-09-11
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多