日期:2014-05-18  浏览次数:20895 次

请教控件 progressBar1和trackBar1问题。
public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }

  private void timer1_Tick(object sender, EventArgs e)
  {  
  if (progressBar1.Value<=90) 
  progressBar1.Value = progressBar1.Value + 10;
  else if (progressBar1.Value == 100)
  progressBar1.Hide();
  }
  private void trackBar1_Scroll(object sender, EventArgs e)
  {
  progressBar1.Value = trackBar1.Value;
  }
请问下为什么这样写那个trackBar1控件不随者控件 progressBar1一起动?

------解决方案--------------------
Timer有什么用?trackBar1_Scroll应该没问题。。。
try
private void trackBar1_Scroll(object sender, EventArgs e)
{
progressBar1.Value = trackBar1.Value;
if (progressBar1.Value == 100)
progressBar1.Hide(); 
}
------解决方案--------------------
不用timer progressBar1也会动的,因为你在trackBar1_Scroll把trackBar1的值赋给了progressBar1
private void trackBar1_Scroll(object sender, EventArgs e) 

progressBar1.Value = trackBar1.Value; 
if (progressBar1.Value == 100) 
progressBar1.Hide();
else
progressBar1.Show(); 
}
------解决方案--------------------
private void trackBar1_Scroll(object sender, EventArgs e) 

progressBar1.Value = trackBar1.Value; 

这个根本是多余的,而且没有任何用处