Поделиться через


ProgressBar.Minimum Свойство

Определение

Возвращает или задает минимальное значение диапазона элемента управления.

public:
 property int Minimum { int get(); void set(int value); };
public int Minimum { get; set; }
member this.Minimum : int with get, set
Public Property Minimum As Integer

Значение свойства

Минимальное значение диапазона. Значение по умолчанию — 0.

Исключения

Значение, указанное для свойства, меньше 0.

Примеры

В следующем примере кода используется ProgressBar элемент управления для отображения хода выполнения операции копирования файлов. В примере используются Minimum свойства и Maximum свойства для указания диапазона, эквивалентного количеству файлов для ProgressBar копирования. Код также использует Step свойство с PerformStep методом для увеличения значения ProgressBar файла в виде файла. В этом примере требуется, чтобы у вас был ProgressBar созданный элемент pBar1 управления, созданный в объекте Form, и что создан метод CopyFile (возвращающий логическое значение, указывающее, что операция копирования файлов была завершена успешно) которая выполняет операцию копирования файлов. Код также требует, чтобы массив строк, содержащих файлы для копирования, был создан и передан CopyWithProgress в метод, определенный в примере, и что метод вызывается из другого метода или события в примере Form.

private:
   void CopyWithProgress( array<String^>^filenames )
   {
      // Display the ProgressBar control.
      pBar1->Visible = true;

      // Set Minimum to 1 to represent the first file being copied.
      pBar1->Minimum = 1;

      // Set Maximum to the total number of files to copy.
      pBar1->Maximum = filenames->Length;

      // Set the initial value of the ProgressBar.
      pBar1->Value = 1;

      // Set the Step property to a value of 1 to represent each file being copied.
      pBar1->Step = 1;

      // Loop through all files to copy.
      for ( int x = 1; x <= filenames->Length; x++ )
      {
         // Copy the file and increment the ProgressBar if successful.
         if ( CopyFile( filenames[ x - 1 ] ))
         {
            // Perform the increment on the ProgressBar.
            pBar1->PerformStep();
         }
      }
   }
private void CopyWithProgress(string[] filenames)
{
    // Display the ProgressBar control.
    pBar1.Visible = true;
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1;
    // Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length;
    // Set the initial value of the ProgressBar.
    pBar1.Value = 1;
    // Set the Step property to a value of 1 to represent each file being copied.
    pBar1.Step = 1;
    
    // Loop through all files to copy.
    for (int x = 1; x <= filenames.Length; x++)
    {
        // Copy the file and increment the ProgressBar if successful.
        if (CopyFile(filenames[x-1]))
        {
            // Perform the increment on the ProgressBar.
            pBar1.PerformStep();
        }
    }
}
Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
    ' Display the ProgressBar control.
    pBar1.Visible = True
    ' Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1
    ' Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length
    ' Set the initial value of the ProgressBar.
    pBar1.Value = 1
    ' Set the Step property to a value of 1 to represent each file being copied.
    pBar1.Step = 1

    ' Loop through all files to copy.
    Dim x As Integer
    for x = 1 To filenames.Length - 1
        ' Copy the file and increment the ProgressBar if successful.
        If CopyFile(filenames(x - 1)) = True Then
            ' Perform the increment on the ProgressBar.
            pBar1.PerformStep()
        End If
    Next x
End Sub

Комментарии

Это свойство задает нижнее ограничение Value свойства. При изменении ProgressBar значения Minimum свойства элемент управления перезабирается, чтобы отразить новый диапазон элемента управления. Если значение Value свойства равно значению Minimum свойства, индикатор выполнения пуст. Чтобы изменить значение индикатора выполнения, используйте свойство с PerformStep методом, используйте StepIncrement метод или задайте значение Value свойства напрямую.

Применяется к

См. также раздел