TL;DR
持續執行的進度條
停止:
完整程式碼範例:
持續執行的進度條
ProgressBar progressBar = new ProgressBar();
progressBar.Style = ProgressBarStyle.Marquee;
progressBar.MarqueeAnimationSpeed = 10;
停止:
progressBar.Style = ProgressBarStyle.Continuous;
progressBar.MarqueeAnimationSpeed = 0;
完整程式碼範例:
public Form1()
{
ProgressBar progressBar = new ProgressBar();
progressBar.Size = new Size(500, 30);
progressBar.Location = new Point(10, 10);
this.Controls.Add(progressBar);
Button button = new Button();
button.Text = "Start";
button.Location = new Point(progressBar.Right + 10, 10);
button.Size = new Size(100, 30);
button.Click += (sender, e) =>
{
if (button.Text.Equals("Start"))
{
button.Text = "Stop";
progressBar.Style = ProgressBarStyle.Marquee;
progressBar.MarqueeAnimationSpeed = 10;
}
else
{
button.Text = "Start";
progressBar.Style = ProgressBarStyle.Continuous;
progressBar.MarqueeAnimationSpeed = 0;
}
};
this.Controls.Add(button);
}
留言
張貼留言
如果有任何問題、建議、想說的話或文章題目推薦,都歡迎留言或來信: a@ruyut.com