winform怎样显示一个活动的类似滚动进度条的窗体
form1为主窗体,form2自己做的类似滚动进度条的窗体,问一下为什么实例化的form中的进度条不滚动。求大神解释,代码在下面
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool Dir = true;
Form2 form = new Form2();
private void timer1_Tick(object sender, EventArgs e)
{
int x =form.Location.X;
if (x < 0)
Dir = true;
if (x < form.panel1.Size.Width - form.pictureBox1.Size.Width && Dir)
{
x = x + 15;
form.pictureBox1.Location = new Point(x, -1);
Application.DoEvents();
}
else
{
Dir = false;
x = x - 15;
form.pictureBox1.Location = new Point(x, -1);
Application.DoEvents();
}
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
form.ShowDialog();
}
}
}