我目前有一個按鈕對象,用於啓動播放wav文件以及進度條和計時器,所有這些都是Visual Studio 2010中的工具箱對象。問題是當我打開表單時,進度條自動開始填充。我怎樣才能讓它只在點擊按鈕時啓動?獲取進度條以單擊按鈕開始
這裏是我的代碼至今:
private void playsong1_Click(object sender, EventArgs e)
{
SoundPlayer sndplayer = new SoundPlayer(Programming_assignment.Properties.Resources.Back_In_Black);
sndplayer.Play();
timer1.Enabled = true;
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value < 256)
{
progressBar1.Value++;
}
}
也許你可以在這裏查看「如何在C#中實現進度條?」http://stackoverflow.com/questions/1259949/how-do-i-implement-a-progress-bar-in-c「 –