我想加载Form2。 Form2有一个datagridview,因为它有大量的数据需要时间加载。
我希望在表单加载时生成进度条。 我遇到了BackgroundWorker,但我不确定它是如何工作的。
答案 0 :(得分:3)
网上有很好的教程可以解决这个问题:
http://www.codeproject.com/Tips/83317/BackgroundWorker-and-ProgressBar-demo
一个youtube解释它甚至取消:
https://www.youtube.com/watch?v=2qQgctSi4iY
要记住的关键是使用
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
和
//animate from your current color to red ValueAnimator
anim = ValueAnimator.ofInt(view.getBackgroundColor(),
Color.parseColor("#FF0000"));
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
view.setBackgroundColor(animation.getAnimatedValue());
}
});
anim.start();
正如演示中所解释的那样。