1 つのボタンのクリック イベントで以下のコードを記述し、ProgressBar とfor
ループを同時に連携させたいと考えています。だから最初は始めたtimer1
private void Button_Click(object sender, EventArgs e)
{
this.timer1.Start();
if (comboBox.SelectedIndex == 0)
{
TextBox.Clear();
for (int j = 0; j < N; j++)
for (int i = 0; i < N; i++)
{
TextBox.Text += array[i, j].ToString()+" , " ;
}
}
}
しかし、ボタンをクリックすると、最初に TextBox が塗りつぶされ始め(for
ループが機能します)、次に timer1 が機能し始め、ProgressBar がインクリメントし始めます。
私は Visual Studio 2010、Windows Forms アプリケーションを使用し、以下のコードを記述しますtimer1
。
private void timer1_Tick(object sender, EventArgs e)
{
this.ProgressBar.Increment(1);
}
どのようにすれば、起動と動作を同時に行うように設定できますか?