Progress Bar C#

后端 未结 2 733
终归单人心
终归单人心 2021-01-15 05:58

I have a progress bar to show the status of the program loading songs into the library.

    foreach (Song s in InitializeLibrary())
    {
        Library.Add         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-15 06:56

    You need to set the Maximum property of the progress bar so that it can calculate percentages when you increment the Value:

    var items = InitializeLibrary();
    pBar.Maximum = items.Length;
    foreach (Song s in items)
    {
        Library.AddSong(s);
        pBar.Value++;
    }
    

提交回复
热议问题