Я хочу, чтобы индикатор выполнения запускался, когда пользователь нажимает кнопку «Подтвердить».Однако я могу заставить индикатор выполнения двигаться только тогда, когда щелкаю по нему.Как мне связать мой индикатор выполнения, чтобы начать, когда я нажимаю кнопку «Подтвердить».
private void ValidateButton_Click(object sender, EventArgs e)
{
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(FileNameBox.Text);
while ((line = file.ReadLine()) != null)
{
System.Console.WriteLine(line);
counter++;
}
file.Close();
System.Console.WriteLine("There were {0} records.", counter);
// Suspend the screen.
System.Console.ReadLine();
}
private void ProgressBar_Click()
{
// Display the ProgressBar control.
ProgressBar.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
ProgressBar.Minimum = 1;
// Set Maximum to the total number of files to copy.
ProgressBar.Maximum = FileNameBox.TextLength;
// Set the initial value of the ProgressBar.
ProgressBar.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
ProgressBar.Step = 1;
// Loop through all files to copy.
for (int x = 1; x <= FileNameBox.TextLength; x++) ;
}
}
FileNameBox - это путь к файлу, выбранный пользователем.Это работает как задумано.